我已经尝试但无法将此t-sql转换为linq。
select title , count(number) as order_number from order
group by title
答案 0 :(得分:2)
会是这样的:
var result = context.order
.GroupBy(p=>p.title)
.Select(p=> new {title = p.Key, order_number = p.Count()})