我有这个查询
SELECT Reaction, COUNT(*) as 'Votes' FROM Member_Reaction mr
WHERE mr.[Entitiy ID] = '259F16A0-9635-4F58-B645-0AEBAAC09D46'
GROUP BY Reaction
如何将其转换为Linq?
答案 0 :(得分:7)
类似的东西:
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,字符串或任何正确的类型。)