他们当然可以!
如果您使用 Entity Framework 的 Code First 方法执行此操作,您只需将外键关系作为类型包含在类中:
public class DaySpec
{
public int DaySpecId { get; set; }
public DateTime Open { get; set; }
public DateTime Close { get; set; }
}
public class WeekSpec
{
public int WeekSpecId { get; set; }
public bool booleanOne { get; set; }
public DaySpec[] DaySpecs { get; set; }
}
public class ExceptionHoursSet
{
public int ExceptionHoursSetId { get; set; }
public int RepCount { get; set; }
public int WeekSpecId { get; set; } // set which WeekSpec you are referencing below (for lazy-loading)
public virtual WeekSpec HoursSet { get; set; }
// etc . . .
}
public class Schedule
{
public int ScheduleId { get; set; }
public string Name { get; set; }
public int WeekSpecId { get; set; } // set which WeekSpec you are referencing below (for lazy-loading)
public virtual WeekSpec WeekSpec { get; set; }
public IEnumerable<ExceptionHoursSet> ExceptionHoursSets { get; set; }
}
我可能遗漏了一些属性,但你明白了(在必要时填写)。有不同的方法可以处理这种情况(延迟加载等),这完全取决于您需要对数据做什么。