Can anyone tell where to map Stored-Procedures exactly in Nhibernate.
In class hbm.xml file or newly declared file(hbm.xml) especially for Stored Procedures???
can u tell with reason??
I create a single XML file that contains ALL stored procedure calls, e.g.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<sql-query name="SummaryReport">
exec getSummaryReport :productId
</sql-query>
<sql-query name="FullReport">
exec getFullReport :productId
</sql-query>
</hibernate-mapping>
and mark this as an embedded resource. I can then call me SP like this:-
var results = Session
.GetNamedQuery("SummaryReport")
.SetInt32("productId", productId);
.SetResultTransformer(
new AliasToBeanResultTransformer(typeof(SummaryReport)));
return results.List<SummaryReport>();
This works fine for me but there really isn't a recommended way, its always down to what you feel is right for you.