Linq/C#: Selecting and summing items from the result of a group by?

Posted by Andrew White on Stack Overflow See other posts from Stack Overflow or by Andrew White
Published on 2010-06-07T08:59:35Z Indexed on 2010/06/07 9:02 UTC
Read the original article Hit count: 314

Filed under:
|
|
|
|

Hi,

I have a list like this:

City   Total
Sydney 11
Dublin 9
London 12
Dublin 3
London 9
Sydney 12
I first of all need to Group By City & Sum Total so I have

Sydney 23
Dublin 12
London 21

Next I need to filter for those that entries where the total is > 20

Sydney 23
London 21

And what I finally need is the total of these entries, e.g. 44

I really want to do it in 1 single LINQ statement, possible?

Thx,

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ