【发布时间】:2012-03-07 08:16:19
【问题描述】:
我正在使用基于 NHibernate 约定的映射,并且正在尝试研究如何映射多级继承结构
如果我有以下类结构
class ClassA
class ClassB : ClassA
class ClassC : ClassB
我希望所有三个类都代表一个表 - 数据库中的“ClassC”
在我的配置中,我将 ClassA 定义为 RootEntity
(如此处所述: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));
...
}
生成的架构然后为 ClassB 和 ClassC 创建单独的表,它们都包含在 ClassA 中定义的字段
【问题讨论】:
标签: nhibernate nhibernate-mapping multiple-inheritance nhibernate-mapping-by-code