您好,我正在使用TPH继承来建立类似的可配置项。我的TPH模型如下:
public class baseConfigItem
{
public int ID {get; set;}
public string ExternalText {get; set;}
public string InternalText { get; set; }
public bool Active { get; set; }
public string Group { get; set; }
public int SortOrder { get; set; }
public statusDef status { get; set; }
public virtual ICollection<Order> Orders{get;set;}
public baseConfigItem()
{
this.Orders= new List<Order>();
}
}
public class DoorTypes:baseConfigItem{public DoorTypes():base(){}}
public class WindowType : baseConfigItem { public WindowType():base(){}}
public class WallType : baseConfigItem { public WallType():base(){}}
public class RoofType : baseConfigItem { public RoofType():base(){}}
public class RoofSize : baseConfigItem { public RoofSize():base(){}}
public class DoorSize : baseConfigItem { public DoorSize():base(){}}
public class GardenSize : baseConfigItem { public GardenSize():base(){}}
我需要创建订单实体与子实体的多对多和一对多/多对一关系:
- 订单拥有多个窗户类型
- 订单拥有多个墙壁类型
- 订单拥有多个屋顶类型
- 订单拥有一个屋顶尺寸
- 订单拥有一个门尺寸
- 订单拥有一个花园尺寸
public class Order
{
public int ID {get; set;}
public virtual ICollection<WindowType> WindowTypes {get; set;}
public virtual ICollection<WallType> WallTypes {get; set;}
public virtual ICollection<RoofType> RoofTypes {get; set;}
public RoofSize RoofSize {get; set;}
public DoorSize DoorSize {get; set;}
public GardenSize GardenSize {get; set;}
}
然而,这并没有为RoofTypes、WallTypes等生成多对多关系……我曾经以为public virtual ICollection Orders{get;set;}会被继承。我该如何建立上述继承类与订单之间的多对多和一对多关系?