【发布时间】:2015-01-08 02:25:44
【问题描述】:
Parent 有一个 Child 的集合。 子项对父项 (ParentID) 有一个外键,但该外键可能为空/空白。 我希望实体框架始终为所有父项加载具有空/空白外键的子项。
public class Parent
{
public string ID { get; set; }
public virtual ICollection<Child> Children { get; set; } //Should load it's children AND children without foreign key.
}
public class Child
{
public string ID { get; set; }
public string ParentID { get; set; } //This can be null / blank.
}
【问题讨论】:
标签: c# .net entity-framework entity-framework-6