如何在示例中更改sql查询?

时间:2014-04-01 10:36:45

标签: c# sql linq

我已经尝试但无法将此t-sql转换为linq。

select title , count(number) as order_number from order
group by title

1 个答案:

答案 0 :(得分:2)

会是这样的:

   var result = context.order
                       .GroupBy(p=>p.title)
                       .Select(p=> new {title = p.Key, order_number = p.Count()})