0

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

http://geekswithblogs.net/nharrison/archive/2010/07/09/inheriting-a-class-map-in-fluent-nhibernate.aspx

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.

Ryan Burnham
  • 2,619
  • 3
  • 27
  • 43

1 Answers1

0

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");
}
Firo
  • 30,626
  • 4
  • 55
  • 94