有没有某种方法可以指定“哪里”?动态地在地图上?

发布于 2024-12-13 13:25:42 字数 821 浏览 3 评论 0原文

让我们考虑以下简化的映射:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"  assembly="xxx" namespace="yyy">
  <class name="Customer" table="Customers">
    <id name="Id" column="customerID" type="Int64">
      <generator class="native"/>
    </id>

    <!-- LOOK AT THE WHERE BELOW .-->
    <map where="codeType='BO'" name="Conversions" table="CustomersCodes" >
      <key column="customerID"></key>
      <index   column="codeType" type="AnsiString"/>
      <element column="code" type="AnsiString"/>
    </map>

  </class>
</hibernate-mapping>

我想在代码中从根本上指定位置(粘贴在示例中的映射中),这可能吗?

作为一种可行的替代方案,是否可以使用 QueryOver 或 LinqToNH 只获取映射的键?我确实尝试过链接到 NH,但它抱怨地图不包含实体(是的,因为它是元素的地图,这在 NH 中完全有效,并且在许多情况下对于优化速度很有用)

Lets consider the following simplified mapping:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"  assembly="xxx" namespace="yyy">
  <class name="Customer" table="Customers">
    <id name="Id" column="customerID" type="Int64">
      <generator class="native"/>
    </id>

    <!-- LOOK AT THE WHERE BELOW .-->
    <map where="codeType='BO'" name="Conversions" table="CustomersCodes" >
      <key column="customerID"></key>
      <index   column="codeType" type="AnsiString"/>
      <element column="code" type="AnsiString"/>
    </map>

  </class>
</hibernate-mapping>

I would like to dinamycally specify the where ( that is sticked in the mapping in the sample ) in code, is it possible ?

As a viable alternative, is it possible to fetch just a key of the map with QueryOver or LinqToNH ? I did try with link to NH but it complain that the map does not contain an entity ( true, since it is a map of elements, that is perfectly valid in NH and useful to optimize the speed in many cases )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯下孤影 2024-12-20 13:25:42

也许 NHibernate 过滤器可以在这里帮助您使用 NHibernate 过滤器的上下文数据

Perhaps NHibernate Filters could help you here Contextual data using NHibernate filters

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文