我有一个二元关联:VetAssistant [1..2] ------ * Surgery
。我想限制负责该关联的ICollection<VetAssistant>
的大小。我喜欢它在1到2的范围内。是否可以通过数据注释?
public class Surgery
{
public int Id { get; set; }
public String Description { get; set; }
public virtual ICollection<VetAssitant> VetAssitants { get; set; }
}
[Table("VetAssistants")]
public class VetAssitant : Person
{
public DateTime Hired { get; set; }
public virtual ICollection<Surgery> Surgeries { get; set; }
}