Layered Inheritance Using NHibernate Loquacious Mapping By Code
I am using NHibernate based mapping and I am trying to figure out how to map a multilevel inheritance framework
If I have the following class structure
class ClassA
class ClassB : ClassA
class ClassC : ClassB
and I want all three classes to represent one table - "ClassC" in the database
in my config i have defined ClassA as RootEntity
(as described here: http://fabiomaulo.blogspot.co.nz/2011/04/nhibernate-32-mapping-by-code_13.html )
public static void WithConventions(this ConventionModelMapper mapper, Configuration configuration)
{
var baseEntityType = typeof(ClassA);
mapper.IsRootEntity((type, declared) => baseEntityType.Equals(type.BaseType));
...
}
the resulting schema then creates separate tables for ClassB and ClassC that contain the fields defined in ClassA
+3
source to share