first thing first my question is very similar to this one. In fact, it's the same thing, except that I need to group every user like this below:
- Everyone under 12 (exclusive)
- Then, from 12 - 19
- Then, from 20 - 29
- ...
- More than 80 (inclusive)
Based on the answer from dasblinkenlight in the other question, I was able to do:
var ageStats = vModel
.GroupBy(l => 10 * (l.Age / 10))
.OrderBy(x => x.Key)
.Select(g => new
{
Name = g.Key,
Count = g.Select(l => l.Age).Count()
}).ToList();
For a result set of :
- 0-9
- 10-19
- 20-29
- ...
So what should I do to accomplish the pattern I have to ?
Thank you very much !!