Get the count of items in a GroupBy Linq-to-sql Query?
Posted
by Curtis White
on Stack Overflow
See other posts from Stack Overflow
or by Curtis White
Published on 2010-04-20T19:32:29Z
Indexed on
2010/04/20
19:33 UTC
Read the original article
Hit count: 267
I have a groupby that I groups all elements. I can see the items are there in LinqPad but can't find a way to get the count.
Here is what I have so far:
SurveyResponses.Where( q => q.QuestionId == 4).GroupBy(q => q.AnswerNumeric).Where( g => g.Key == 1)
In Linq Pad I can see there are 4 items in this query. If I do Count it returns 1. I've tried, ToList().Count, Select(x => x).Count, etc.
© Stack Overflow or respective owner