0

次の問題があります。Entity Framework で TPH 継承を構築していますが、サブクラスの既存のプロパティに識別子列を設定する必要があります。例:

public abstract class Building 
{
    //... some properties
    public BuildingType BType { get; set; } // sub class with discriminator property
}

public class BuildingA : Building
{

}

public class BuildingB : Building
{

}

public class BuildingType
{
    //... some properties
    public string Category { get; set; } 
    /*
    discriminator property
    if this property is set to "A" then the building is type BuildingA
    and if is set to "B" then the building is type BuildingB
    */
}

そのため、すべての建物には BuildingType プロパティが必要であり、BuildingType クラスにはプロパティ Category (既に存在する) があり、建物の TPH 継承の識別子となる可能性があります。どうすればこれを達成できますか?

4

0 に答える 0