我有一个如下模型设置:
public class ReportScheduleModel
{
public string Day { get; set; }
public List<ReportTimes> reportTimes { get; set; }
}
public class ReportTimes
{
public byte hourOfDay { get; set; }
public byte minuteOfDay { get; set; }
public string reportType { get; set; }
}
然后我可以使用以下列表格式将整个列表传递回我的控制器:
List<ReportScheduleModel> ReportSchedule
[0]->Day: 'Sunday'
[ReportTimes]: [0]->hourOfDay: '09'
minuteOfDay: '23'
reportType: 'Test1'
[1]->hourOfDay: '08'
minuteOfDay: '11'
reportType: 'Test2'
[1]->Day: 'Sunday'
[ReportTimes]: [0]->hourOfDay: '09'
minuteOfDay: '23'
reportType: 'Test1'
[1]->hourOfDay: '11'
minuteOfDay: '30'
reportType: 'Test1'
[2]->Day: 'Monday'
[ReportTimes]: [0]->hourOfDay: '09'
minuteOfDay: '23'
reportType: 'Test1'
在上面的列表中,您注意到ReportSchedule[0]
两者ReportSchedule[1]
的报告时间完全相同,即“09:23 Test1”。我想要做的是得到一个没有这些重复值的列表,它只保留一个重复的报告时间值。因此,我基于上述内容的理想过滤列表将是:(Day
不分组/唯一无关紧要,只是ReportTimes
基于相同的“日”)
[0]->Day: 'Sunday'
[ReportTimes]: [0]->hourOfDay: '09'
minuteOfDay: '23'
reportType: 'Test1'
[1]->hourOfDay: '08'
minuteOfDay: '11'
reportType: 'Test2'
[1]->Day: 'Sunday'
[ReportTimes]: [0]->hourOfDay: '11'
minuteOfDay: '30'
reportType: 'Test1'
[2]->Day: 'Monday'
[ReportTimes]: [0]->hourOfDay: '09'
minuteOfDay: '23'
reportType: 'Test1'