如何将以下SQL转换为Linq?
select ReqUserID, count(DepartmentID)
from [ReqUsersDeptMat]
where DepartmentID IN (93060,2175)
group by ReqUserID
having count(*) = 2
答案 0 :(得分:0)
试试这种方式
from item in ReqUsersDeptMat
group item by item.ReqUserID into groupedItems
let count = groupedItems.Count()
where count =2
select new { ReqUserID= groupedItems.Key, Num_Of_Departmentid = count };