I'm using dapper in my project to call stored procedures. I've set up the following post call in my API
[HttpPost("{procName}")]
public List<dynamic> RunProcWithParameters(string procName, [FromQuery]Dictionary<string, string> procParameters)
{
var parameters = new DynamicParameters(procParameters);
using var conn = new SqlConnection(_options.Connection);
var result = conn.Query(procName, parameters, commandType: CommandType.StoredProcedure).ToList();
return result;
}
With swagger hooked up in my project, I'm testing out my API by passing in my proc name and parameters with a sample call looking like: https://localhost:7009/StoredProc/MyProcThatIWantToRun?ParameterName=ParameterValue
When I run this, I'm getting the following error:
The member Comparer of type System.Collections.Generic.IEqualityComparer`1[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] cannot be used as a parameter value
I've tried changing my dictionary to be Dictionary<string, object> but no value is passed in when I run this.
What is it that I'm doing wrong / not understanding in this?