asp.net mvc - LINQ group by and order by in C# -


i need convert city list group state , order city within it.

i tried below 1 not able right. appreciate on this.

cities.groupby(g => g.state).select(o => o.orderby(c => c.cityname)); 

try below code

cities.groupby(g => g.state) .select(o =>new {            state = o.key,          cities = o.orderby(c => c.cityname).tolist()}) .tolist(); 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -