如何约束实体框架中ICollection的大小

时间:2016-06-08 08:29:31

标签: c# entity-framework constraints

我有一个二元关联: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; }
}

0 个答案:

没有答案