-
Notifications
You must be signed in to change notification settings - Fork 874
Closed
Description
If you create a parameter, give it DbType.Object and try set an int, it fails.
This was possible on 2.0.11 (I'm not sure if it should be possible)
Dapper will try do this if you give it a dynamic in its parameters, something like this I believe:
dynamic value = 1;
conn.Execute("SELECT :param", new { param = value });Here is a test case:
[Test]
public void ParameterExplicitType2DbTypeObjectFromInt()
{
using (var command = new NpgsqlCommand(@"SELECT * FROM data WHERE field_int4=:param", Conn))
{
var sqlParam = command.CreateParameter();
sqlParam.ParameterName = "param";
sqlParam.DbType = DbType.Object;
sqlParam.Value = 1;
command.Parameters.Add(sqlParam);
command.ExecuteScalar();
}
}I'll have a go at making this work, hopefully without cludging too much :)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels