【问题标题】:'Table with concrete class' mapping using Fluent NHibernate's auto mapping使用 Fluent NHibernate 的自动映射的“具有具体类的表”映射
【发布时间】:2009-03-28 05:54:24
【问题描述】:

是否可以将 Fluent NHibernate 配置为使用“具有具体类的表”继承自动映射对象。在查看自动映射(我已写入文件)时,我有许多从 EntityBase 派生的实体,但我希望 Id 列位于每个表上而不是 EntityBase 表上。

<class name="EntityBase" table="EntityBase" xmlns="urn:nhibernate-mapping-2.2">
    <id name="Id" type="Int32" column="EntityBaseID">
      <generator class="identity" />
    </id>
    <joined-subclass name="CategoryType, ..., Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
      <key column="EntityBaseId" />
      <property name="CategoryTypeGUID">
        <column name="CategoryTypeGUID" />
      </property>
    </joined-subclass>
</class>

我浏览了 Fluent 文档,但看不到任何与此相关的内容。

提前致谢。

【问题讨论】:

    标签: nhibernate fluent-nhibernate


    【解决方案1】:

    您是否在自动映射中设置了IsBaseType 约定?这个特定的约定定义了在您的代码中被视为简单基类的东西,而不是被视为实体继承层次结构一部分的东西。

    AutoPersistenceModel
      /* regular config */
      .WithSetup(s =>
        s.IsBaseType = (type => type == typeof(EntityBase)));
    

    【讨论】:

    • 感谢詹姆斯。我想知道那个约​​定和“Where”方法之间的区别是什么,现在我知道了!
    猜你喜欢
    • 2011-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-18
    相关资源
    最近更新 更多