开发者

Get @Return_Value from stored procedure using Entity

I want to get @Ret开发者_如何学JAVAurn_Value from stored procedure using entity.

Lets say stored procedure is:

CREATE PROCEDURE GetEmployes( @whereSql nvarchar(512) )
AS
BEGIN
    set @tsql = 'select * from Employes where '  + @whereSql
    exec(@tsql)
    return 5
END

Entity imports is as

ObjectResult<Employe> GetEmployes(...)

This is what I need.

int return_value;
var result = db.GetEmpleys("name = .. AND ...", out return_value);
if (return_value == 5)
     // do something on this exit code
List<Employe> result.ToList<Employe>() ;

I am using Visual Studio 2008

TIA


The notion of the int return value is SQL Server specific. I don't believe that the EF, which is designed to be DB-server-agnostic, supports it.

So you have to use proper output params, not the int return value. That should not be a problem. Worst case, wrap the proc in another proc which returns the int return value of the first as an output of the second.

Finally, I hope this is just an example, as your demo proc introduces an SQL injection vulnerability.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜