你如何用nHibernate调用存储过程?
具体来说,有两种情况我使用存储过程:返回标量值并返回映射到实体的一组结果。
How do you call a stored procedure with nHibernate?
Specifically there are two cases where I am using store procedures: to return a scalar value and to return a set of results mapped to entities.
最满意答案
该文档建议使用以下方法映射存储过程的命名查询:
<sql-query name="selectAllEmployments_SP"> <return alias="emp" class="Employment"> <return-property name="employee" column="EMPLOYEE"/> <return-property name="employer" column="EMPLOYER"/> exec selectAllEmployments //stored procedure call here </sql-query>这可以通过使用:
IQuery q = sess.GetNamedQuery("selectAllEmployments_SP");这将在NHibernate 1.2.0文档的13.2.2节(映射存储过程)和9.3.2(查询命名查询)中讨论。 https://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/querysql.html#sp_query
The documentation suggests the following for mapping a named query for a stored procedure:
<sql-query name="selectAllEmployments_SP"> <return alias="emp" class="Employment"> <return-property name="employee" column="EMPLOYEE"/> <return-property name="employer" column="EMPLOYER"/> exec selectAllEmployments //stored procedure call here </sql-query>This could be called by using :
IQuery q = sess.GetNamedQuery("selectAllEmployments_SP");This is discussed in section 13.2.2 (mapping stored procedure) and 9.3.2 (querying named query) of the NHibernate 1.2.0 documentation. https://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/querysql.html#sp_query
更多推荐
nHibernate,过程,存储,return,电脑培训,计算机培训,IT培训"/> <meta name="descr
发布评论