C# 基于鉴别器(类型)列的实体框架导航属性

C# 基于鉴别器(类型)列的实体框架导航属性,c#,linq,entity-framework,navigation-properties,C#,Linq,Entity Framework,Navigation Properties,我有3个实体 Provider { ProviderId -PK Name } ProviderType1 { ProviderType1Id-PK Name } ProviderType2 { ProviderType2Id-PK Name } 然后我有另一个名为PreferredProvider的实体,它用作提供者之间的映射器,用于从ProviderType1或ProviderType2设置首选提供者 PreferredProvider

我有3个实体

Provider
{
    ProviderId -PK
    Name
}

ProviderType1
{
    ProviderType1Id-PK
    Name
}

ProviderType2
{
    ProviderType2Id-PK
    Name
}
然后我有另一个名为PreferredProvider的实体,它用作提供者之间的映射器,用于从ProviderType1或ProviderType2设置首选提供者

PreferredProvider
{
    PreferredProviderId - PK
    ProviderId - FK Provider
    PrefProviderId - FK ProviderType1,ProviderType2 
    PrefProviderType - discriminator column to detect type of provider

    // navigation properties
    [ForeignKey("PrefProviderId")]
    ProviderType1 Prov1

     // navigation properties
    [ForeignKey("PrefProviderId")]
    ProviderType2 Prov2

}
因此,我使用如下导航属性

GetDbSet<PreferredProvider>().Where(p => p.ProviderId == 4 && p.PrefProviderType == 'ProviderType1').Select(p => p.Prov1).ToList();
GetDbSet()。其中(p=>p.ProviderId==4&&p.PrefProviderType==ProviderType1')。选择(p=>p.Prov1).ToList();
我的问题是,当我处理一种类型,即ProviderType1(s)时,这很好,但是当我必须为一个包含ProviderType1(s)和ProviderType2(s)的提供程序获取所有首选提供程序时,如何组合。实际上,我可以使用左连接来获取,但需要更好的方法。请帮助我