如何使用 Nhibernate 的 loquacious 映射将 sql 函数映射为命名查询?
我已将所有 NHibernate xml 映射文件替换为冗长的映射(通过代码映射)。我唯一不知道的是是否可以使用冗长的映射来定义这个命名查询:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping namespace="Domain" assembly="Domain" xmlns="urn:nhibernate-mapping-2.2">
<sql-query name="MyFunction">
<query-param name="Inputparam1" type="Int32"/>
<query-param name="Inputparam2" type="Int32"/>
<return-scalar column="ResultParam" type="Int32"/>
<![CDATA[ select MyFunction(:Inputparam1,:Inputparam2) as ResultParam ]]>
</sql-query>
</hibernate-mapping>
有谁知道这是否可能,那么如何做到这一点或为我指明正确的方向?
提前致谢, 问候,特德
I have replaced all my NHibernate xml mapping files by loquacious mappings (mapping by code). The only thing I can't figure out is if it is possible to define this named query using loquacious mappings:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping namespace="Domain" assembly="Domain" xmlns="urn:nhibernate-mapping-2.2">
<sql-query name="MyFunction">
<query-param name="Inputparam1" type="Int32"/>
<query-param name="Inputparam2" type="Int32"/>
<return-scalar column="ResultParam" type="Int32"/>
<![CDATA[ select MyFunction(:Inputparam1,:Inputparam2) as ResultParam ]]>
</sql-query>
</hibernate-mapping>
Does anyone know if it's possible, and so how to do it or point me in the right direction?
Thanks in advance,
Regards, Ted
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您仍然可以混合映射,即通过代码使用映射的所有新功能,并且仍然拥有一些 HBM 命名映射文件。
解决方案非常简单,首先您需要将 web.config (或外部 nhibernate 配置文件)定义为:-
然后相应地配置 NHibernate:-
我写了一个 关于此的博客文章。
You can still mix your mappings, that is use all the new juiciness of mapping by code and still have some of your HBM named mapping files.
The solution is quite simple, first you need to define your web.config (or external nhibernate config file) as:-
Then configure NHibernate accordingly:-
I have written a blog post regarding this.