Here are the domain model classes:
public abstract class BaseClass
{
...
}
public class ChildClass : BaseClass
{
...
}
Note that the parent class is abstract and this is what gives me some difficulties when comes the time to map with fluent nhibernate. My discriminator is a byte (tinyint in the DB). Because it is not a string and I can't manage to set a discriminator value on the base class, this does not work (taken from the mapping class for BaseClass):
DiscriminateSubClassesOnColumn<byte>("Type")
.SubClass<ChildClass>()
.IsIdentifiedBy((byte)OperationType.Plan)
.MapSubClassColumns(p => { ... })
The error message I get is:
Class Initialization method UnitTest1.MyClassInitialize threw exception. NHibernate.MappingException: NHibernate.MappingException: Could not format discriminator value to SQL string of entity BaseClass ---> System.FormatException: Input string was not in a correct format..
The following post seems to explain what happens. They give a solution with xml but not with fluent nhibernate: http://forum.hibernate.org/viewtopic.php?t=974225
Thanks for the help.