1

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?

1 Answer 1

3

The Name property (as you've found out) returns the name of the function in the CLR space.

What you want to use is the MappedName property, defined as (emphasis mine):

Gets the name of the parameter in the database function.

Note that the call to the Parameters property on the MetaFunction class 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 same MetaParameter instance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.