有关如何将此Linq to Entities(VB.Net)查询更改为Group by L2_ID列的任何建议,并将计算的列diff聚合为该组的Sum。
由于
From l In Level3s
Join a In BaseLines On l.L3_ID Equals a.L3_ID
Order By l.L2_ID
Select Activity = l.L2_ID, Diff = (a.ACT_DATE.Day - l.ACT_DATE.Day)
答案 0 :(得分:0)
尝试连续两次查询:
Dim q = From l In context.Level3s _
Join a In contexts.BaseLines On l.L3_ID Equals a.L3_ID _
Order By l.L2_ID _
Select Activity = l.L2_ID, Diff = (a.ACT_DATE.Day - l.ACT_DATE.Day)
Dim q1 = From el In q _
Group By Key = el.Activity Into G = Sum(el.Diff) _
Select Key, G