假设我有一个实体,代表重复发生的事件:

public class ReccuringEvent : EntityBase, IReccuringEvent
{
    public virtual ICollection<ReccuringElementBase> IncludedElements { get; private set; }
    public virtual ICollection<ReccuringElementBase> ExcludedElements { get; private set; }
}

假设我有一堆派生自ReccuringElementBase的实体(此类包含每月,每周的一些共享数据) . 例如 . :

public class ReccuringElementBase
{
    public DateTime _startFrom { get; private set; }
    public DateTime _endBy { get; private set; }
    ...
}

public class Monthly : ReccuringElementBase
{
    public int MonthToPerform { get; private set; }
    ...
}

我想要的是在List <<'ReccuringElementBase> InlcudedElements / ExcludedElements中保存它们(Weekly,Monthly等) . 当您明确地将派生类用作属性或属性集合(如SomeReccuringRule实体中的每月/每周)并将它们映射到数据库表(使用每个层次结构表(TPH),每种类型的表(TPT))时,实体框架可以处理这种情况,每混凝土表(TPC)):

public class SomeReccuringRule : EntityBase
{
    public Monthly { get; private set; }
    public Weekly { get; private set; }
    ...
}

但是,我有一些不同的东西 . Can Entity Framework可以将ICollection <'ReccuringElementBase>类型的属性(必须包含每月,每周等)映射到数据库,如果是,它是如何实现的?