根据子类型映射到不同的视图 [英] Mapping to a different view based on child type
问题描述
它看起来像我可以使用一个通用的映射类来处理继承
但我怎样才能有条件地映射到一个不同的基于子类型的视图?我看到一个EntityType属性,但它表示它的过时,并将在下一个版本中被私有。
作为一个例子,我有一个ContactInfo的基类是标准的联系类型但值来自不同的地方,取决于联系类型,这我会通过SQL视图处理。
使用任何映射引用的实体来自不同的表
class ContactInfo
{
public virtual long Id {get ;组; }
public virtual ContactDetails Details {get;组; }
}
$ b public ContactInfoMap
{
...
ReferencesAny(x => x.Details)
.EntityIdentifierColumn( (contact)
.IdentityType< long>()
.AddMetaValue< FooContactDetails>(1)
.AddMetaValue< BarContactDetails> 4\" );
}
So i have a situation where i have common base type but i need to map to a different view based on the child type.
It looks like i can use a generic mapping class to handle the inheritance
But how can i conditionally map to a different view based on the child type? I see an EntityType property but it says its obsolete and will be made private in the next version.
As an example i have a base class of ContactInfo is standard between contact types but the values come from different places depending on the contact type, this I'll handle through the sql view.
using any mapping the referenced entity comes from a different table
class ContactInfo
{
public virtual long Id { get; set; }
public virtual ContactDetails Details { get; set; }
}
public ContactInfoMap
{
...
ReferencesAny(x => x.Details)
.EntityIdentifierColumn("details_id")
.EntityTypeColumn("contactType")
.IdentityType<long>()
.AddMetaValue<FooContactDetails>("1")
.AddMetaValue<BarContactDetails>("4");
}
这篇关于根据子类型映射到不同的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!