[英]How can I convert “SELECT col, COUNT(*)” to a Linq expression?
I have this query我有这个查询
SELECT Reaction, COUNT(*) as 'Votes' FROM Member_Reaction mr
WHERE mr.[Entitiy ID] = '259F16A0-9635-4F58-B645-0AEBAAC09D46'
GROUP BY Reaction
How can I convert this to Linq?如何将其转换为 Linq?
Something like:就像是:
var query = from item in db.MemberReactions
where item.ID == id
group item by item.Reaction into g
select new { Reaction = g.Key, Count = g.Count() };
(Where id
is the ID you're looking for - as a GUID, or a string, or whatever the right type is.) (其中
id
是您要查找的 ID - 作为 GUID、字符串或任何正确的类型。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.