为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

呼唤远方 2018-08-22 09:06:49
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新人,希望各位高手解答,谢谢
查看完整描述

2 回答

?
aluckdog

TA贡献1847条经验 获得超7个赞

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


查看完整回答
反对 回复 2018-08-27
?
慕沐林林

TA贡献2016条经验 获得超9个赞

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


查看完整回答
反对 回复 2018-08-27
  • 2 回答
  • 0 关注
  • 535 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信