首页 新闻 会员 周边 捐助

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

0
悬赏园豆:200 [已解决问题] 解决于 2011-03-30 17:11

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

illegals的主页 illegals | 初学一级 | 园豆:0
提问于:2011-03-22 17:16
< >
分享
最佳答案
0

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)
            });

收获园豆:200
彭汉生 | 小虾三级 |园豆:1233 | 2011-03-22 18:03
其他回答(1)
0

大概这么个意思,照着你的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)
                        }

peter cheng | 园豆:431 (菜鸟二级) | 2011-03-23 09:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册