You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With SQL Server, every helper that sports a WHERE predicate, when receiving some key property of type string, is liable to incur implicit conversion. string gets translated into nvarchar but if the database column type is either varchar or char(n) the column types will be mismatched, the column will be auto-converted, and performance tanks. Dealing with this idiosyncrasy in Dapper.Contrib appears to be only narrowly possible: there is no attribute with which to specify the database column type, no hook to override the type at render time, and no native way to cast the value in the generated predicate. There is zero native support for DbType, SqlDbType, or Dapper's DbString.
The best I can come up with is instructing GetDatabaseType to use a hypothetical implementation like
However, it pays to be aware that AppendColumnNameEqualsValue gets used both for the update column and the predicate, and even if that is desirable it lacks context and falls apart the moment two identically named columns have incompatible types.
The only practically feasible remedies I can see are changing the database column types, if possible, or avoiding the various predicate aware helpers entirely.
The text was updated successfully, but these errors were encountered:
With SQL Server, every helper that sports a
WHERE
predicate, when receiving some key property of typestring
, is liable to incur implicit conversion.string
gets translated intonvarchar
but if the database column type is eithervarchar
orchar(n)
the column types will be mismatched, the column will be auto-converted, and performance tanks. Dealing with this idiosyncrasy in Dapper.Contrib appears to be only narrowly possible: there is no attribute with which to specify the database column type, no hook to override the type at render time, and no native way to cast the value in the generated predicate. There is zero native support forDbType
,SqlDbType
, or Dapper'sDbString
.The best I can come up with is instructing
GetDatabaseType
to use a hypothetical implementation likeHowever, it pays to be aware that
AppendColumnNameEqualsValue
gets used both for the update column and the predicate, and even if that is desirable it lacks context and falls apart the moment two identically named columns have incompatible types.The only practically feasible remedies I can see are changing the database column types, if possible, or avoiding the various predicate aware helpers entirely.
The text was updated successfully, but these errors were encountered: