Commit 353b682f authored by Marc Gravell's avatar Marc Gravell

make sure that SetValue is the last thing to happen when there is a type-handler

parent 00224317
...@@ -4002,30 +4002,35 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity) ...@@ -4002,30 +4002,35 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
{ {
p = (IDbDataParameter)command.Parameters[name]; p = (IDbDataParameter)command.Parameters[name];
} }
p.Direction = param.ParameterDirection;
if (handler == null) if (handler == null)
{ {
p.Value = val ?? DBNull.Value; p.Value = val ?? DBNull.Value;
} else if (dbType != null && p.DbType != dbType)
{
handler.SetValue(p, val ?? DBNull.Value);
}
p.Direction = param.ParameterDirection;
var s = val as string;
if (s != null)
{
if (s.Length <= 4000)
{ {
p.Size = 4000; p.DbType = dbType.Value;
} }
var s = val as string;
if (s != null)
{
if (s.Length <= 4000)
{
p.Size = 4000;
}
}
if (param.Size != null)
{
p.Size = param.Size.Value;
}
} }
if (param.Size != null) else
{
p.Size = param.Size.Value;
}
if (dbType != null && p.DbType != dbType)
{ {
p.DbType = dbType.Value; if (dbType != null) p.DbType = dbType.Value;
if (param.Size != null) p.Size = param.Size.Value;
handler.SetValue(p, val ?? DBNull.Value);
} }
if (add) if (add)
{ {
command.Parameters.Add(p); command.Parameters.Add(p);
......
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