我在实体框架中成功使用了自引用表。但我不知道如何获得所需深度的记录?
这应该是什么逻辑?
模型 :
public class FamilyLabel
{
public FamilyLabel()
{
this.Children = new Collection<FamilyLabel>();
this.Families = new Collection<Family>();
}
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int FamilyLabelId { get; set; }
public string FamilyLabelName { get; set; }
public virtual FamilyLabel Parent { get; set; }
public int JamaatId { get; set; }
public virtual Jamaat Jamaat { get; set; }
public virtual ICollection<Family> Families { get; set; }
public virtual ICollection<FamilyLabel> Children { get; set; }
}