score:2

Accepted answer

for the count you just need this query:

int total = pieces
    .where(x => x.count > 0)
    .groupby(x => new { x.count, x.date, x.description })
    .sum(g => g.key.count);

so you can access all key properties of the grouping.

this returns 85 for your initial sample and 108 if you add the new piece.


Related Query

More Query from same tag