Page 1 of 1

Stored procedures and functions with EF

Posted: Fri 22 Jan 2010 16:55
by acerdas
Hello

We haven't been able to understand how you should call stored procedures or functions that return scalar values with Enttity Framework.

Whe have checked the article http://www.devart.com/blogs/dotconnect/?p=5 but it refers to stored procedures returning cursors not string (for example)

Can you help us by telling us which are the necesary steps to accomplish that?

Thanks

Posted: Tue 26 Jan 2010 09:12
by Shalex
We have answered you by e-mail. Is the problem resolved?

Posted: Mon 29 Mar 2010 23:11
by tleese22
Would like to see these answers in the posting so others can see the solution (like me) who has the same question.

Posted: Tue 30 Mar 2010 08:16
by Shalex
If a stored procedure returns scalar value, it is necessary to adjust the settings of the method in Method Editor of Devart Entity Developer. Assuming your stored procedure looks like

Code: Select all

CREATE or REPLACE PROCEDURE GET_STRING(strParam OUT Varchar)
IS
BEGIN
select 'Hello!' into strparam from dual;
END;
Return Type in Method Editor should be set to None, and make sure that the Direction property of out parameter is set to Output in the Parameters tab. Save the model. You can call this method from your code now:

Code: Select all

string tmp = null;
using (DataSourceModel1.DataSourceModel1Entities context = new DataSourceModel1.DataSourceModel1Entities()){
    context.Get_String(ref tmp);
}
If you encounter any difficulties, please specify the exact error message and the steps we should follow to reproduce it in our environment.