开发者

LINQ SELECT COUNT(*) AND EmployeeId

开发者 https://www.devze.com 2022-12-23 14:32 出处:网络
I have a table like below: EmployeeId EmployeeName RequestId RequestName EmployeeId RequestId I need to a to assign requests in a sequential fashion(those who has mininum number of开发者_如何学运

I have a table like below:

EmployeeId
EmployeeName

RequestId
RequestName

EmployeeId
RequestId

I need to a to assign requests in a sequential fashion(those who has mininum number of开发者_如何学运维 requests).

Can I know how to get employee who has minimum requests using linq???

Thanks, Mahesh


Assuming the class containing EmployeeID and RequestID (the third table) is named "Foo", it could be

(from f in db.Foos
 group by f.EmployeeID into g
 orderby g.Count()
 select new { f.EmployeeID, g.Count() }).First()

This is drycoded and may be wrong. =)

0

精彩评论

暂无评论...
验证码 换一张
取 消