LINQ group 两个表

CCPressDataContext cp = new CCPressDataContext();
            var ee = from e in cp.ACC_BookFactCost
                     select e;
            if (CTN != "")
            {
                ee = ee.Where(x => x.ChoiceThemeNo.Contains(CTN));
            }
            if (BookNo != "")
            {
                ee = ee.Where(x => x.COM_BookInfoOne.BookNo.Contains(BookNo));
            }
            if (BookName != "")
            {
                ee = ee.Where(x => x.COM_BookInfoOne.BookName.Contains(BookName));
            }
            if (department != "")
            {
                ee = ee.Where(x => x.COM_BookInfoOne.COM_Departments.DepartmentName.Contains(department));
            }
            if (ZB != "")
            {
                ee = ee.Where(x => x.COM_BookInfoOne.ResponsibleEditor.Contains(ZB));
            }
            if (start != "")
            {
                ee = ee.Where(x => Convert.ToInt32(x.AccountPeriod)>=Convert.ToInt32(start));
            }
            if (end != "")
            {
                ee = ee.Where(x => Convert.ToInt32(x.AccountPeriod) <= Convert.ToInt32(end));
            }
            var aa = from a in ee
                     group a by a.ChoiceThemeNo into g
                     select new { ChoiceThemeNo = g.Key, M1 = g.Sum(x => x.M1), M2 = g.Sum(x => x.M2), M3 = g.Sum(x => x.M3), M4 = g.Sum(x => x.M4), M5 = g.Sum(x => x.M5), M6 = g.Sum(x => x.M6), M7 = g.Sum(x => x.M7), M8 = g.Sum(x => x.M8), M9 = g.Sum(x => x.M9), M10 = g.Sum(x => x.M10), M11 = g.Sum(x => x.M11), M12 = g.Sum(x => x.M12), M13 = g.Sum(x => x.M13), M14 = g.Sum(x => x.M14), M15 = g.Sum(x => x.M15), M16 = g.Sum(x => x.M16), M17 = g.Sum(x => x.M17) ,BookInfo=from b in cp.COM_BookInfoOne where b.ChoiceThemeNo==g.Key select b
                                };

            return aa;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值