select dbd.AllotRecID, dbd.ProductID, sum(rec.Weight) weight from AllotDetail dbdinner join OutputRec recon dbd.AllotRecID = rec.AllotRecID and dbd.ProductID = rec.ProductID group by dbd.AllotRecID, dbd.ProductID, dbd.Weighthaving dbd.Weight > sum(rec.Weight)
本人LINQ新人,希望各位高手解答,谢谢
AllotDetail dbdinner join这里是不是错了?
AllotDetail dbd inner join??
var result = ctx.AllotDetail.GroupJoin
(
ctx.OutputRec,
a => a.AllotRecID,
o => o.AllotRectID,
(a, c) =>
new
{
ProductID = a.ProductID,
Weight = c.Sum(s => s.Weight)
});
大概这么个意思,照着你的sql手写的,写错了就自己改改:
from p in AllotDetail
from q in OutputRec
group p by p.AllotRecID,p.ProductID,p.Weight into g
where g.Weight > weight
select new {
AllotRecID,ProductID,
weight = g.Sum(p => p.Weight)
}