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