我有下表
Members
Id, GroupId, Age
1, 1, 12
2, 1, 20
3, 1, 33
4, 2, 12
5, 2, 7
如何编写LINQ查询,该查询将为我提供每个组中最早成员的列表?
结果应为
Id, GroupId, Age
3, 1, 33
4, 2, 12
答案 0 :(得分:3)
from m in members
group m by m.GroupId into g
select g.OrderByDescending(m => m.Age).First()