IExecuteResult doesn''t implement IFuncitionResult

I hate to pick nits, but is there a reason why IExecuteResult does not implement IFunctionResult?

Jim

[121 byte] By [JimWooley] at [2008-1-9]
# 1

The item returned via IExecuteResult's Value property may implement IFunctionResult. This happens when the return value is ISingleResult or IMultipleResults.

MattWarren-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 2

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.

Jim
JimWooley at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 3

The 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:

Code Snippet

foreach(var item in db.MySproc(x,y,z)) {

...

}

If you need to know the return value you can do this:

Code Snippet

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'.

MattWarren-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...

Visual Studio Orcas

Site Classified