IExecuteResult doesn''t implement IFuncitionResult
I hate to pick nits, but is there a reason why IExecuteResult does not implement IFunctionResult?
Jim
I hate to pick nits, but is there a reason why IExecuteResult does not implement IFunctionResult?
Jim
The item returned via IExecuteResult's Value property may implement IFunctionResult. This happens when the return value is ISingleResult or IMultipleResults.
Under what circumstances would it NOT return a IFunctionResult? Since it requires Object ReturnValue which is all that IFunctionResult consists of, why not enforce it as part of IExecuteResult as well?
Like I said, I'm just picking at nits on this one. There's plenty of bigger fish to fry.
JimThe reason that IFunctionResult is paired with ISingleResult and not IExecuteResult is due to the need to return it out of the stored proc method and the DataContext so your calling code can actually get access to it. There are actually two return values from the sproc, the resulting sequence and the official 'RETURN' value. However, getting access to the return value is actually rare, most sprocs don't return a numeric result, just rows.
If you don't need to know the sprocs actual return value you can just write this code:
foreach(var item in db.MySproc(x,y,z)) {
...
}
If you need to know the return value you can do this:
var result = db.MySproc(x,y,z);
foreach(var item in result) {
...
}
var returnValue = result.ReturnValue;
The reason IExecuteResult.ReturnValue is not typed to be IFunctionResult, is because not all 'Functions' need this additional return value. For example, a user-defined function that returns a string would have its string return value in IExecuteResult.ReturnValue. Maybe IFunctionResult would have been better named as 'IFunctionWithAdditionalReturnValue'.