我有一个日期时间值的通用列表:weekADates
我有一个时间表实体的通用列表: response.TimeTableWeek
public class TimeTable
{
public int LessonNumber { get; set; }
/// <summary>
/// For each day and lessonnumber in the week there is a schooclass code assigned
/// </summary>
public IDictionary<DayOfWeek,string> WeeklySchoolclassCodes { get; set; }
}
这段代码需要改成 LINQ 查询:
var periodList = new List<Period>();
foreach (DateTime date in weekADates)
{
foreach (TimeTable timetable in response.TimeTableWeek)
{
for (int i = 0; i < timetable.WeeklySchoolclassCodes.Count; i++)
{
var p = new Period();
p.LessonNumber = timetable.LessonNumber + 1;
p.LessonDate = date;
p.SchoolclassCode = timetable.WeeklySchoolclassCodes[date.DayOfWeek];
periodList.Add(p);
}
}
}
我尝试了 .Select 和 .SelectMany 的许多变体,但我找不到解决方案。
这就是周期列表的样子。
您如何将其更改为 linq?