Commit 611dfed0 authored by BlackjacketMack's avatar BlackjacketMack

Added support for ICustomQueryParameters to be members of a dictionary that...

Added support for ICustomQueryParameters to be members of a dictionary that can then be passed into a new DynamicParameters object.

Generally, working with an IDictionary<string,object> and DynamicParameters has worked well.  However, when one of the entries in the dictionary is an ICustomQueryParameter, it would blow up in the SqlMapper.LookupDbType method.  This allows parameters that are part of a dictionary to simply call 'AddParameter' passing in the command and name.
parent 885a8d46
......@@ -3112,8 +3112,9 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
var dbType = param.DbType;
var val = param.Value;
string name = Clean(param.Name);
var isCustomQueryParameter = typeof(SqlMapper.ICustomQueryParameter).IsAssignableFrom(val.GetType());
if (dbType == null && val != null) dbType = SqlMapper.LookupDbType(val.GetType(), name);
if (dbType == null && val != null && !isCustomQueryParameter) dbType = SqlMapper.LookupDbType(val.GetType(), name);
if (dbType == DynamicParameters.EnumerableMultiParameter)
{
......@@ -3121,6 +3122,10 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
SqlMapper.PackListParameters(command, name, val);
#pragma warning restore 612, 618
}
else if (isCustomQueryParameter)
{
((SqlMapper.ICustomQueryParameter)val).AddParameter(command, name);
}
else
{
......@@ -3610,4 +3615,4 @@ public partial class FeatureSupport
#endif
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment