LINQ Group by SUM [英] LINQ Group by SUM

查看:149
本文介绍了LINQ Group by SUM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下查询

Dim Query = From c In DB.Crt _
                        Where c.Member.Locked = False _
                        And c.Member.Verified = True _
                        And c.Ct > 0 _
                        Order By c.Ct Ascending _
                        Select New With {.MemberID = c.MemberID, _
                                         .Ct = c.Ct}

我如何通过 c.ct

类似于 SUM OF(c.Ct)> 0

推荐答案

试试这个:

Try this:

Dim Query =
    From c In DB.Crt _
    Where c.Member.Locked = False _
    And c.Member.Verified = True _
    And c.Ct > 0 _
    Order By c.Ct Ascending _
    Group c.Ct By Key = c.MemberID Into Cts = Group _
    Select New With { .MemberID = Key, .Ct = Cts.Sum() }

这篇关于LINQ Group by SUM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆