Reputation: 100322
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?
Upvotes: 1
Views: 142
Reputation: 1500065
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.)
Upvotes: 7