【发布时间】:2011-12-21 11:22:37
【问题描述】:
我想使用流利的 nhibernate 或 nhibernate 本身(我的意思是 hbm 文件)组合每类表和每层次表策略,但我不知道如何。我更喜欢流利而不是 hbm,但如果不可能,那么 hbm 也可以。我通过在 fluent 中引入 Entity 作为 ClassMap 和所有其他作为 SubClassMap 来测试这一点,但是在 fluent 生成的 hbm 文件中,Entity 是一个类,而所有其他都是连接类,这不是我想要的。我将在下面更详细地描述这个问题。
类层次结构:
public class Entity
{
public int ID { get; set; }
public string Name { get; set; }
}
public abstract class Person : Entity
{
public string Phone { get; set; }
}
public class SystemUser : Person
{
public string Password { get; set; }
}
我想有一张实体表和一张人表以及所有类型的表(所有子类)。我的意思是我想对实体使用每类表策略,对人使用每层次表策略和SystemUser 类。数据库结构是这样的:
EntityTable(ID(PK),Name)
PersonTable(EntityID(PK,FK),Phone,Password)
任何帮助表示赞赏。
【问题讨论】:
标签: nhibernate inheritance hierarchy fluent class-hierarchy