LINQ 返回多组数据、组合数据
LINQ 返回多组数据、组合数据
DAL层查询方法
C# 全选
/// <summary>
/// 查询纸盒资料(返回多组数据)
/// </summary>
/// <param name="cartonCode"></param>
/// <returns></returns>
public res_CartonData GetDataByCode(string cartonCode)
{
var q = _Database.GetQueryable<dt_Carton>();
var master = q.Where(w => w.CartonCode == cartonCode).FirstOrDefault();
if (master != null)
{
//查询图片查询参数
var input = new req_Images()
{
DocType = ImageDocType.Carton.ToString(),
DocNo = master.isid,
};
//从dt_Images中获取对应的图片
var img = new dal_Images(_Loginer).GetByDocType(input);
var result = new res_CartonData()
{
Master = master,
CartonImage = img,
dt_CartonMaterialsFormula = _Database.GetQueryable<dt_CartonMaterialsFormula>().Where(w => w.CartonCode == cartonCode).ToList(),
dt_CartonProcessSettings = _Database.GetQueryable<dt_CartonProcessSettings>().Where(w => w.CartonCode == cartonCode).ToList(),
dt_CartonSpecConvert = _Database.GetQueryable<dt_CartonSpecConvert>().Where(w => w.CartonCode == cartonCode).ToList(),
dt_CartonWrapQtySettings = _Database.GetQueryable<dt_CartonWrapQtySettings>().Where(w => w.CartonCode == cartonCode).ToList(),
};
return result;
}
else
{
return null;
}
}
返回数据模型
C# 全选
/// <summary>
/// 纸盒资料组合数据
/// </summary>
public class res_CartonData
{
public dt_Carton Master { get; set; }
public dt_Images CartonImage { get; set; }
public List<dt_Carton> MasterList { get; set; }
public List<dt_CartonMaterialsFormula> dt_CartonMaterialsFormula;
public List<dt_CartonProcessSettings> dt_CartonProcessSettings;
public List<dt_CartonSpecConvert> dt_CartonSpecConvert;
public List<dt_CartonWrapQtySettings> dt_CartonWrapQtySettings;
}
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
CSFramework.EF C/S框架网