将SQL QUERY转换为LINQ TO ENTITIES

时间:2016-05-03 22:00:45

标签: sql entity-framework linq ef-code-first

我不会为运营商选择前4名(在用户表中有最大数量)

SELECT TOP 4  [Operator], COUNT(Operator) as opCount
  FROM [Users] 
  Group by Operator
  order by opCount desc

1 个答案:

答案 0 :(得分:0)

请尝试这样的事情。

var result = db.Users.Take(4).GroupBy(y=>y.Operator).ToList();