不支持嵌套查询。 Operation1 ='的GroupBy'操作2 =' MultiStreamNest'

时间:2016-02-01 04:46:14

标签: entity-framework linq linq-to-sql linq-to-entities

这是在linqpad中运行的linq没有得到任何错误,但是当我运行我们的项目时,我收到此错误(不支持嵌套查询。操作1 =' GroupBy' Operation2 =&#39 ; MultiStreamNest'),你可以给出soln

  var ledgerReport = (from i in db.Items
             join si in db.SalesInvoiceDetails on i.ItemCode equals si.ItemCode
             join cat in db.categories on i.catCode equals cat.catCode
             join locw in
                 (from loc in db.LocationStocks
                  group loc by new { loc.ItemCode } into g1
                  select new { Qty1 = (Decimal?)g1.Sum(x => x.Qty) ?? 0, g1.Key.ItemCode }) on i.ItemCode equals locw.ItemCode into we
             where si.DispatchDate >= startdate && si.DispatchDate <= enddate
             group si by new
             {
                 si.ItemCode,
                 i.Description,
                 Qtt = (Decimal?)we.Sum(x => x.Qty1) ?? 0,
                 i.LowestLevel
             } into g
             select new
             {
                 g.Key.ItemCode,
                 g.Key.Description,
                 qoh = g.Key.Qtt,
                 quantity = (Decimal?)g.Sum(x => x.QtyOrdered) ?? 0,
                 lowlevel = g.Key.LowestLevel
             }).tolist();

0 个答案:

没有答案