这个SQL语句怎么翻译成LINQ语句?急啊

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新人,希望各位高手解答,谢谢


呼唤远方
浏览 536回答 2
2回答

aluckdog

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)                        }
打开App,查看更多内容
随时随地看视频慕课网APP