How can I write the following sql code in LINQ
select count(1) Cnt,state
from yourtable
group by state
order by Cnt desc Limit 5
I am trying somthing like this
(from topPro in CS.state group topPro by new {
Name = topPro.state.Name
} into g
select new{
StateName = g.Key.Name,
Count = g.Count(x=>x.state)
}
Count = g.Count()instead ofCount = g.Count(x=>x.state)