Commit dc1d0270 authored by Marc Gravell's avatar Marc Gravell

Use a different constant for list parameters

parent f22447df
...@@ -427,14 +427,14 @@ internal static DbType LookupDbType(Type type, string name) ...@@ -427,14 +427,14 @@ internal static DbType LookupDbType(Type type, string name)
} }
if (typeof(IEnumerable).IsAssignableFrom(type)) if (typeof(IEnumerable).IsAssignableFrom(type))
{ {
// use xml to denote its a list, hacky but will work on any DB return DynamicParameters.EnumerableMultiParameter;
return DbType.Xml;
} }
throw new NotSupportedException(string.Format("The member {0} of type {1} cannot be used as a parameter value", name, type)); throw new NotSupportedException(string.Format("The member {0} of type {1} cannot be used as a parameter value", name, type));
} }
/// <summary> /// <summary>
/// Identity of a cached query in Dapper, used for extensability /// Identity of a cached query in Dapper, used for extensability
/// </summary> /// </summary>
...@@ -1541,7 +1541,7 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn ...@@ -1541,7 +1541,7 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
continue; continue;
} }
DbType dbType = LookupDbType(prop.PropertyType, prop.Name); DbType dbType = LookupDbType(prop.PropertyType, prop.Name);
if (dbType == DbType.Xml) if (dbType == DynamicParameters.EnumerableMultiParameter)
{ {
// this actually represents special handling for list types; // this actually represents special handling for list types;
il.Emit(OpCodes.Ldarg_0); // stack is now [parameters] [command] il.Emit(OpCodes.Ldarg_0); // stack is now [parameters] [command]
...@@ -2458,6 +2458,7 @@ public void Dispose() ...@@ -2458,6 +2458,7 @@ public void Dispose()
/// </summary> /// </summary>
partial class DynamicParameters : SqlMapper.IDynamicParameters partial class DynamicParameters : SqlMapper.IDynamicParameters
{ {
internal const DbType EnumerableMultiParameter = (DbType)(-1);
static Dictionary<SqlMapper.Identity, Action<IDbCommand, object>> paramReaderCache = new Dictionary<SqlMapper.Identity, Action<IDbCommand, object>>(); static Dictionary<SqlMapper.Identity, Action<IDbCommand, object>> paramReaderCache = new Dictionary<SqlMapper.Identity, Action<IDbCommand, object>>();
Dictionary<string, ParamInfo> parameters = new Dictionary<string, ParamInfo>(); Dictionary<string, ParamInfo> parameters = new Dictionary<string, ParamInfo>();
...@@ -2620,8 +2621,8 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity) ...@@ -2620,8 +2621,8 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
if (dbType == null && val != null) dbType = SqlMapper.LookupDbType(val.GetType(), name); if (dbType == null && val != null) dbType = SqlMapper.LookupDbType(val.GetType(), name);
if (dbType == DbType.Xml) if (dbType == DynamicParameters.EnumerableMultiParameter)
{ // actually represents "in" lists {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
SqlMapper.PackListParameters(command, name, val); SqlMapper.PackListParameters(command, name, val);
#pragma warning restore 612, 618 #pragma warning restore 612, 618
......
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