开发者

Datatype convert problem

开发者 https://www.devze.com 2023-01-20 04:28 出处:网络
In a DB, I have a SP return a bit result, like: declare @temp bit; --...... return @temp; In EF, I imported this SP as a function and return scarlars Boolean.

In a DB, I have a SP return a bit result, like:

declare @temp bit; 
--......
return @temp;   

In EF, I imported this SP as a function and return scarlars Boolean. In domain service I called this function as:

public bool CallSP()
{
    var result =  this.ObjectContext.MySp();
    return (bool)result;
}

Then got this error:

Cannot convert type 'System.Data.Objects.ObjectResult<bool?>' to 'bool'

How开发者_开发知识库 do I resolve this problem?


Try this:

public bool? CallSP()
{
     var result =  this.ObjectContext.MySp().First();
     return (bool?)result;
}


Try this:

public bool? CallSP()
{
     var result =  this.ObjectContext.MySp();
     return (bool?)result;
}
0

精彩评论

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