开发者

Help with LINQ statement

开发者 https://www.devze.com 2023-01-05 13:21 出处:网络
If I was just wanting the earliest [event] [startTime] I\'d write: events.Min(ev => ev.StartTime); How can I extend this to say:

If I was just wanting the earliest [event] [startTime] I'd write:

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

How can I extend this to say:

"select the [startTime] for the [eve开发者_开发知识库nt] that has the earliest [appointment] [startTime]"

(An [event] has an Appointments collection of [appointment])


Sort by min appointment start time and take the first, something like:

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

精彩评论

暂无评论...
验证码 换一张
取 消