有没有某种方法可以指定“哪里”?动态地在地图上?
让我们考虑以下简化的映射:
<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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许 NHibernate 过滤器可以在这里帮助您使用 NHibernate 过滤器的上下文数据
Perhaps NHibernate Filters could help you here Contextual data using NHibernate filters