TPH and Many to Many Relationships

Hi, I am using TPH inheritance to create similar custom elements. My TPH Model:

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(){}}

Then I need to create many for many and 1, from one to many / many to one with children with entities of order:

  • Order has many WindowTypes
  • The order has many WallTypes
  • There are many types of RoofTypes in the order.
  • Order has one RoofSize
  • Order has one DoorSize
  • Order has one 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;}
}

However, this does not create many, many relationships for RoofTypes, WallTypes, etc. I assumed that public virtual ICollection Orders {get; set;} will be inherited. How can I establish the above inherited classes with a many to many and one to many relationship?

+4
1

. (, , "StatusDef" bool, .) "poof" - . , , . . SQL-.

.

0

All Articles