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:

enter image description here

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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -