我有这段代码。
var foundAppointments = ServiceLink.FindAppointments(User, SiteSecureKey);
var MondayAppointments = foundAppointments.SelectMany(x => x.Where(y => y.StartTime.Date.DayOfWeek == DayOfWeek.Monday)).ToList();
现在我有一个全局列表,我也会添加每天的约会,例如周一、周二、周三等。
然后我运行这个:
Appointments.Add(MondayAppointments); ..........
有什么比写信更能让我在周一到周日的约会中进行的吗?
var TuesdayAppointments = foundAppointments.SelectMany(x=>x.Where(y => y.StartTime.Date.DayOfWeek == DayOfWeek.Tuesday)).ToList();
var WednesdayAppointments = foundAppointments.SelectMany(x=>x.Where(y => y.StartTime.Date.DayOfWeek == DayOfWeek.Wednesday)).ToList();
var ThursdayAppointments = foundAppointments.SelectMany(x=>x.Where(y =>y.StartTime.Date.DayOfWeek == DayOfWeek.Thursday)).ToList();
var FridayAppointments = foundAppointments.SelectMany(x=>x.Where(y => y.StartTime.Date.DayOfWeek == DayOfWeek.Friday)).ToList();
var SaturdayAppointments = foundAppointments.SelectMany(x => x.Where(y => y.StartTime.Date.DayOfWeek == DayOfWeek.Saturday)).ToList();
var SundayAppointments = foundAppointments.SelectMany(x => x.Where(y => y.StartTime.Date.DayOfWeek == DayOfWeek.Saturday)).ToList();
Appointments.Add(TuesdayAppointments);
Appointments.Add(WednesdayAppointments);
Appointments.Add(ThursdayAppointments);
Appointments.Add(FridayAppointments);
Appointments.Add(SaturdayAppointments);
Appointments.Add(SundayAppointments);
有任何想法吗?