tags:

views:

32

answers:

1

Hi

I want to call the Stored procedure from My nHibernate Application thats stored Procedure return the List and i will return back to the UI How to call the SP can any one help me on this?

+1  A: 

You can use the following example. In you mapping file define the query

<sql-query name="MyNameQuery">
        <return-scalar column="SomeColumn" type="String"/>
        <![CDATA[exec proc_MyProc ?]]>
</sql-query>

For the call you can do following

ISQLQuery objQuery = MySession.GetNamedQuery("MyNameQuery") as ISQLQuery;
                    objQuery.SetParameter(0, "1"); // stored procedure expects a parameter, not used here
                    var myResult = objQuery.List<string>();
Fahad
i want to call my sp from the application insted of creating a mapping and the domain object for that how do i do that
bharat
this is what i mean nhibernate call Stored Procedure to Return a Dataset Without a Mapping Entity
bharat
you can use the Session.Connection property to get the IDbConnection and call the stored procedure from there.
Fahad