Reputation: 488
I need to rewrite this sql statement in Linq.
select hand,count(hand) as Hands, deviceid from individualhands
where deviceid = '977aed93-d1f1-4f7a-a6fa-6bc3ea7d863b'
group by hand, deviceid
Can anybody help? :)
Upvotes: 1
Views: 45
Reputation: 5803
Try this:
var query = individualHands
.Where(r => r.deviceid == '977aed93-d1f1-4f7a-a6fa-6bc3ea7d863b')
.GroupBy(r => new { r.hand, r.deviceid })
.Select(g => new { hand = g.Key.hand, deviceid = g.Key.deviceid, Count = g.Count() });
Upvotes: 1