public class MyRows
{
public string StartStop { get; set; }
public string EndStop { get; set; }
public TimeSpan StartTime { get; set; }
public TimeSpan EndTime { get; set; }
public string Day { get; set; }
}
List<MyRows> lmr = new List<MyRows>();
lmr.Add(new MyRows { StartStop = "a", EndStop = "b", StartTime = new TimeSpan(09, 00, 00), EndTime = new TimeSpan(11, 00, 00),Day=DayOfWeek.Sunday.ToString() });
lmr.Add(new MyRows { StartStop = "a", EndStop = "b", StartTime = new TimeSpan(09, 00, 00), EndTime = new TimeSpan(11, 00, 00), Day = DayOfWeek.Sunday.ToString() });
lmr.Add(new MyRows { StartStop = "a", EndStop = "b", StartTime = new TimeSpan(10, 00, 00), EndTime = new TimeSpan(12, 00, 00), Day = DayOfWeek.Tuesday.ToString() });
lmr.Add(new MyRows { StartStop = "a", EndStop = "b", StartTime = new TimeSpan(10, 30, 00), EndTime = new TimeSpan(12, 00, 00), Day = DayOfWeek.Sunday.ToString() });
lmr.Add(new MyRows { StartStop = "a", EndStop = "b", StartTime = new TimeSpan(09, 00, 00), EndTime = new TimeSpan(13, 00, 00), Day = DayOfWeek.Tuesday.ToString() });
lmr.Add(new MyRows { StartStop = "a", EndStop = "b", StartTime = new TimeSpan(09, 00, 00), EndTime = new TimeSpan(11, 00, 00), Day = DayOfWeek.Thursday.ToString() });
lmr.Add(new MyRows { StartStop = "a", EndStop = "b", StartTime = new TimeSpan(11, 00, 00), EndTime = new TimeSpan(12, 00, 00), Day = DayOfWeek.Thursday.ToString() });
我想在StartStop,EndStop,StartTime,EndTime(相同TimeSpans)和DayOfWeek
的基础上找到重复项例如,在上面的列表“
中答案 0 :(得分:0)
这里你没有复杂性,
var result = lmr.Where(i => lmr.Any(o => YourCondition(i,o) && i != o));
//up to you
private bool YourCondition(MyRow i, MyRow o)
{
return i.StartTime >= o.StartTime && i.EndTime <= o.EndTime && i.Day == o.Day;
}