Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fluent NHibernate to query stored procedure without an hbm.xml mapping

Tags:

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

like image 255
rahul Avatar asked May 07 '13 09:05

rahul


1 Answers

I assume you use the standard

Session.GetNamedQuery(....

instead, you can use

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

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

Actually there's this post

like image 104
icepicker Avatar answered Oct 05 '22 21:10

icepicker