如何在Lambda和LINQ中执行此查询?
select COUNT(*) as total, int_page
from dbo.tbl_usuarios_online
group by int_page
order by total desc
我不想使用:
var lambda = ctx.tbl_usuarios_online.**SqlQuery**()
答案 0 :(得分:1)
试试这个:
var result = ctx.tbl_usuarios_online.GroupBy(x => x.int_page)
.Select(group => new { total = group.count(),
int_page = group.Key })
.OrderByDescending(y => y.total);