如何转换"SELECT col, COUNT(*)"到Linq表达式
本文关键字:quot COUNT Linq 表达式 col 何转换 SELECT 转换 | 更新日期: 2023-09-27 18:01:48
我有这个查询
SELECT Reaction, COUNT(*) as 'Votes' FROM Member_Reaction mr
WHERE mr.[Entitiy ID] = '259F16A0-9635-4F58-B645-0AEBAAC09D46'
GROUP BY Reaction
如何将其转换为Linq?
类似于
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() };
(其中id
是您正在寻找的ID -作为GUID,或字符串,或任何正确的类型)