更新时间:2023-02-15 18:03:37
我认为无法映射.您不能将关系的一侧的两个端点关联到关系的另一侧的一个端点.您可能需要这样的东西:
I think it is not possible to map this. You cannot relate two endpoints on one side to one single endpoint on the other side of a relationship. You will probably need something like this:
public partial class Equipment
{
public int Id { get; set; }
public List<EquipmentSet> GlobalEquipmentSets { get; set; }
public List<EquipmentSet> ModelSpecificEquipmentSets { get; set; }
public IEnumerable<EquipmentSet> EquipmentSets
{
get
{
return GlobalEquipmentSets.Concat(ModelSpecificEquipmentSets);
// catch cases when one or both of the sets are null.
}
}
}
EquipmentSets
在这里只是一个只读的帮助程序,未映射到数据库.
EquipmentSets
is here only a readonly helper which isn't mapped to the database.
然后您可以在Global
和GlobalEquipmentSets
之间创建多对多关系,并在ModelSpecific
和ModelSpecificEquipmentSets
之间创建另一个多对多关系.
You can then create a many-to-many relationship between Global
and GlobalEquipmentSets
and another many-to-many relationship between ModelSpecific
and ModelSpecificEquipmentSets
.