仅 QueryOver <one to many> 属性

QueryOver Only <one to many> property

我正在使用 NHibernate 和 QueryOver。我有一个名为 Parent 的聚合根和两种子实体。我有 Child 实体是我聚合的一部分,而 QUChild 实体不是我聚合的一部分,仅用于 JOIN 子句查询结束。

如何区分映射文件中的两个子实体?

<class name="Parent" table="Parent" schema="dbo">
      <bag name="Childs" inverse="true" cascade="all-delete-orphan" />
        <key>
        </key>
        <one-to-many class="Child" />
      </bag>
      <bag name="QUChilds"  /> <!-- which attribute must be set to do nothing? -->
        <key>
        </key>
        <one-to-many class="QUChild" />
      </bag>
</class>

好吧,什么都不做。 NHibernate 不会预先加载,如果您不从加载的父实体访问它,也不会 lazy-load 它。

并且默认的级联是none,所以就按照你映射的样子保留它。 (但我会添加 inverse="true" 以防代码更改导致稍后在该集合中添加一些子项。)