I have a domain model like this:
In the mapping, I am using a table-per-hierarchy structure where all LineItemOption
subtypes are stored in a single table and a named "OptionType" is used as a discriminator. This column isn't mapped to a property and isn't visible to the domain.
// FluentNHibernate ClassMap for LineItemOption
Map(lio => lio.Description);
DiscriminateSubClassesOnColumn("OptionType");
// FluentNHibernate SubclassMap for ColorOption
DiscriminatorValue("C")
// FluentNHibernate SubclassMap for GenericOption
DiscriminatorValue("O")
I am using the QueryOver API to fetch a list of Order
s that contain a LineItem
with a LineItemOption
of a specific type containing a specific description.
private void AddColorRestrictionToQuery(
IQueryOver<Order, Order> query,
string color)
{
query.JoinQueryOver<LineItem>(order => order.LineItems)
.JoinQueryOver<LineItemOption>(line => line.Options)
.Where(opt => opt.Description.IsLike(color))
.Where(opt => opt is ColorOption); // See below
}
This results in NHibernate adding "WHERE OptionType = MyNamespace.Entities.ColorOption" to the query. Instead of using the discriminator value, it seems to be using the fully-qualified namespace+class name.
Why is NHibernate using the class name instead of its discriminator?