开发者

LINQ SELECT COUNT(*) AND EmployeeId

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜