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
Post a Comment