I'm using Fluent NHibernate with DiscriminateSubClassesOnColumn() to support subclassing. The column used to discriminate between subclasses is not mapped to an actual property on the entity.
How do I create a query which returns only entities of a given type?
Here's my try, where propertyName is the name of my discriminating column and value is the type name:
return _db.CreateCriteria<T>()
.Add(Restrictions.Eq(propertyName, value))
.List<T>();
However this gives me the error "could not resolve property: Type of: [my entity type]", which is because the entity itself doesn't have the property. If I add the property to my entity and map it I get another error: "System.IndexOutOfRangeException : Invalid index 7 for this SqlParameterCollection with Count=7."