【发布时间】:2014-10-29 15:14:20
【问题描述】:
我首先使用实体框架代码。 我有 2 个具有虚拟 ICollection 属性的非常相似的类。 这是其中的一个集合类:
public class Name
{
public int Id{ get; set;}
[MaxLength(64)]
[Index(IsUnique = true)]
[Required]
public string Value { get; set; }
public virtual ICollection<NameVariant> Variants { get; set; }
}
public class NameVariant
{
public int Id{ get; set;}
[MaxLength(64)]
[Index(IsUnique = true)]
[Required]
public string Value { get; set; }
public int ParentId { get; set; }
public virtual Name Parent { get; set; }
}
在一种情况下,我从 Variants 获得 EntityCollection,在另一种情况下获得 HashSet。 它取决于什么?如何从两个类中获取 EnityCollection?
【问题讨论】:
标签: c# entity-framework code-first