I’m writing a function to call a stored procedure given an IDictionary of arguments.
[Function(Name = "dbo.GetTrackingInfo")]
[ResultType(typeof(Shipment))]
[ResultType(typeof(Piece))]
[ResultType(typeof(Item))]
public IMultipleResults GetTrackingInfo(IDictionary<string, object> arguments)
{
var method = (MethodInfo)MethodInfo.GetCurrentMethod();
var argumentsArr = this.Mapping.GetFunction(method).Parameters
.Select(p => arguments.ContainsKey(p.Name)
? NullableExtensions.Convert(arguments[p.Name], p.ParameterType)
: null)
.ToArray();
return (IMultipleResults)this.ExecuteMethodCall(this, method, argumentsArr);
}
I expected Mapping.GetFunction(method).Parameters to return the parameters of the SP, but instead it returned the parameters of this method. Is there any simple way to get the parameters of the underlying SP?
The
Nameproperty (as you’ve found out) returns the name of the function in the CLR space.What you want to use is the
MappedNameproperty, defined as (emphasis mine):Note that the call to the
Parametersproperty on theMetaFunctionclass does return information about the parameters of the underlying SP; it’s a mapping, so it has both the SP information along with the information about the CLR representation, associated with the sameMetaParameterinstance.