1

我需要在 Linq 中重写这个 sql 语句。

select hand,count(hand) as Hands, deviceid from individualhands
where deviceid = '977aed93-d1f1-4f7a-a6fa-6bc3ea7d863b'
group by hand, deviceid

有人可以帮忙吗?:)

4

1 回答 1

1

试试这个:

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() });
于 2012-12-01T12:24:06.687 回答