我有这些对象:
public class Class
{
public Guid Id {get;set;}
public string Name {get;set;}
public virtual ICollection<Schedule> Schedules{get;set;}
}
public class Schedule
{
public Guid Id {get;set;}
public virtual DayOfTheWeekId {get;set;}
public virtual DayOfTheWeek {get;set;}
public DateTime StartTime {get;set;}
public DateTime EndTime {get;set;}
}
我当前的查询看起来像这样,但我得到了这个异常:至少一个对象必须实现 IComparable。:
Repository
.Get(c => c.Schedules.Any(s => s.DayOfTheWeekTypeId == dayOfTheWeekId))
.OrderBy(e => e.Schedules.OrderBy(s => s.StartDateTime)).ToList()
当我设置时间时,我总是使用同一天,因为我需要在一周中的某些日子上课。这就是 DayOfTheWeek 对象发挥作用的地方。这就是我设置时间的方式:
var schedule = new Schedule{
StartDateTime = new DateTime(1999,1,1) + new TimeSpan(9, 15, 0),
EndDateTime = new DateTime(1999,1,1) + new TimeSpan(9, 15, 0),
DayOfTheWeekTypeId = 1
}
更新:
考虑到这一点,我想我可能想要分组......