刚开始,不懂绑定语法是哪个,怎样限制多条件,多表联合查询 某个数据。
public decimal ZhiXingShuLiang(Guid HeTongHao, Guid HuoWei)
{
//初始化查询条件
Expression> whereLamdba = null;
whereLamdba = whereExpression.And(whereLamdba, x => x.ID_HeTong == HeTongHao);
whereLamdba = whereExpression.And(whereLamdba, x => x.ID_HuoWei == HuoWei);
//条件查询:合同号
if (HeTongHao != null && V_ChuRuKu.Count(y => y.ID_HeTong == HeTongHao) != 0) //执行时间、查到合同号之后查询合同明细 分几个货位
{
whereLamdba = whereExpression.And(whereLamdba, x => x.ID_HeTong == HeTongHao);
}
//条件查询 : 货位号
if (HuoWei != null && V_ChuRuKu.Count(y => y.ID_HuoWei == HuoWei) != 0) //上传状态3和6、合同号和货位号用whereAnd,循环
{
whereLamdba = whereExpression.And(whereLamdba, y => y.ID_HuoWei == HuoWei);
}
//获取查询结果
List<VW_ChuRuKuXinXi> list = V_ChuRuKu.FindList(whereLamdba).ToList();
decimal ZXL;
var zhiXingLiang = from a in list
where a.ID_HeTong == HeTongHao && a.ID_HuoWei == HuoWei
select new { a.JingZhong };
ZXL = (decimal)zhiXingLiang.Sum(a => a.JingZhong);
return ZXL;
}
#endregion