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