4

こんにちは、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(){}}

次に、注文エンティティを持つ子エンティティとの多対多および 1、1 対多/多対 1 の関係を作成する必要があります。

  • オーダーに多くの WindowType があります
  • オーダーに多くの WallType があります
  • 注文に多数の屋根タイプがあります
  • オーダーには 1 つのルーフサイズがあります
  • オーダーには 1 つの DoorSize があります
  • オーダーには 1 つの GardenSize があります
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;} が継承されると想定していました。上記の継承されたクラスを多対多および 1 対多の順序で確立するにはどうすればよいでしょうか?

4

1 に答える 1