Fluent NHibernate 查询存储过程,无需 hbm.xml 映射 [英] Fluent NHibernate to query stored procedure without an hbm.xml mapping

查看:33
本文介绍了Fluent NHibernate 查询存储过程,无需 hbm.xml 映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么方法可以在不创建 hbm.xml 文件映射的情况下在 Fluent Nhibernate 中查询存储过程?

Is there any way to query stored procedure in Fluent Nhibernate without creating an hbm.xml file mapping?

推荐答案

我假设你使用标准

Session.GetNamedQuery(....

相反,您可以使用

var result = Session.CreateSQLQuery("exec MyStoredProc :pUserId, :pIsLocked")
                    .AddEntity(typeof(MyDomainObject))
                    .SetParameter("pUserId", userId)
                    .SetParameter("pIsLocked", isLocked)
                    .List<MyDomainObject>();

这允许您调用存储过程但仍然返回域对象(或列表)而无需 .hbm.xml 文件.

This allows you to call the stored proc but still get back a domain object (or list of) without needing a .hbm.xml file.

其实有这个帖子

这篇关于Fluent NHibernate 查询存储过程,无需 hbm.xml 映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆