我计划在子查询中使用它,但无法找出将以下查询转换为 LINQ 的正确语法:
select ChapterID, min(MeetingDate)
from ChapterMeeting
group by ChapterID
我计划在子查询中使用它,但无法找出将以下查询转换为 LINQ 的正确语法:
select ChapterID, min(MeetingDate)
from ChapterMeeting
group by ChapterID
var query = myDataContext.ChapterMeeting
.GroupBy(cm => cm.ChapterID)
.Select(g => new {
g.Key,
MinMeetingDate = g.Min(cm => cm.MeetingDate)
});
好吧,艾米打败了我,但如果你想用“理解”语法来查看它:
var q = (
from cm in context.ChapterMeeting
group cm by cm.ChapterID into cmg
select new {
ChapterID = cmg.Key,
FirstMeetingDate = cmg.Min(cm => cm.MeetingDate)});