-
-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Description
Updating a model containing null in bytes[] property causes an error:
"Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query."
This is the cause of passing parameters as Dictionary<string, object> to Dapper.
Dapper converts the dictionary to DynamicParameters without knowing the DbType of the passed null value.
SqlDbCommand adds the new parameter with DbType.String (by default) and null convered to DbNull.Value.
For binary and varbinary columns DBNull.Value does not work without setting the DbType, while other column types works fine.
Reference code in Dapper: https://github.com/DapperLib/Dapper/blob/a31dfd3dd4d7f3f2580bd33c877199d7ef3e3ef9/Dapper/DynamicParameters.cs#L271
Metadata
Metadata
Assignees
Labels
No labels