1

I'm trying to execute a store procedure like this:

public bool Test(){
    var searchItem=base.Database.SqlQuery<QueryEntity>("exec nameOfMyProcedure @param1={0}",param13).FirstOrDefault();
    if(searchItem!=null){
        return searchItem.Output1;
    }
    else{
        return false;
    }
private class QueryEntity{
    public bool Output1{get;set;}
}

I've one Return in the stored procedure

Unfortunately, searchItem always returns null.

Have you an idea how I can resolve that?

I'm using SQL server and C#.

4

3 回答 3

0

Your stored procedure is returning more that one columns. That can be the reason for the error you are getting.

于 2013-04-17T12:09:39.260 回答
0

You can try something like this

base.Database.SqlQuery<IEnumerable<string>>("exec nameOfMyProcedure @param1={0},@param2={1},@param3={2}",param1,param2,param3)

basically this is an example and you need to do is, look into the structure of what your stored procedure returns and then use suitable object for parsing.

Here i am assuming all the returns values are string.

于 2013-04-17T12:11:28.447 回答
0

Find the solution. It's not really proper but.. It's work

I create a new stored procedure which return 1 output like this

Select @Return_value as Return

instead of

Return @Return_value
于 2013-04-18T11:41:09.150 回答