C# List Group By with where -
hi i'm trying group c# list. how looks.
name user fred true fred false fred true joe true joe true max false max true
result:
this how wanted after group by, how can in c#?
you can group name , use enumerable.count
predicate here:
var result = list .groupby(x => x.name) .select(g => new { name = g.key, true = g.count(x => x.user == true), false = g.count(x => x.user == false) });
Comments
Post a Comment