Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Stored Procedure with out parameter using Nhibernate

How can I access the value of an out parameter of an oracle stored procedure in the .net code - Oracle stored procedure being called via Nhibernate?

Sample working code would help.

like image 326
publicgk Avatar asked Dec 29 '25 02:12

publicgk


1 Answers

You have to use the latest version of NHibernate (2.1.2).

<sql-query name="ReturnSomethig" callable="true">
   <return class="Somethig" />
   { call ReturnSomethig(:someParameter) }
</sql-query>

The Oracle Stored Procedure need to has the first parameter as a out sys_refcursor parameter.

And you can call the named query like that:

IQuery query = currentSession.GetNamedQuery("ReturnSomethig");
query.SetInt64("someParameter", someParameter);
var somethig = query.List<Somethig>();

And it will work.

like image 173
Douglas Aguiar Avatar answered Dec 31 '25 22:12

Douglas Aguiar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!