帮助LINQ语句

时间:2010-07-05 09:26:22

标签: c# linq

如果我只想要最早的[事件] [startTime],我会写:

events.Min(ev => ev.StartTime);

我如何将其扩展为:

"select the [startTime] for the [event] that has the earliest [appointment] [startTime]"

([事件]有[约会]的约会集合)

1 个答案:

答案 0 :(得分:0)

按照预约开始时间排序,然后选择第一个,例如:

events.OrderBy(ev => ev.Appointments.Min(app => app.StartTime)).First().StartTime;