2 sinat 34369867 sinat_34369867 于 2016.03.30 09:59 提问

C# LINQ 数据绑定及查询

刚开始,不懂绑定语法是哪个,怎样限制多条件,多表联合查询 某个数据。

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 
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!