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
For "legacy application" reasons our database primarily uses CHAR column types with a "Y" or "N" to represent boolean values. We created a BooleanMapper class that appropriately handles the conversion to and from the entity type and the database type.
Assume a table like this:
tbl_entities:
id INT
enabled CHAR
If we query with: db.Query<TblEntities>().Where(e => e.Enabled), the generated SQL effectively becomes SELECT [id], [enabled] FROM tbl_entities WHERE enabled = 1. If the query were to succeed, the BooleanMapper we wrote will appropriately convert the dataset. But, because the enabled field is a char, the conversion to '1' fails during the query execution. If the query provider were aware of the registered mappers, the conversion to 'Y' could happen before the query is sent to the database provider.
The text was updated successfully, but these errors were encountered:
For "legacy application" reasons our database primarily uses CHAR column types with a "Y" or "N" to represent boolean values. We created a
BooleanMapper
class that appropriately handles the conversion to and from the entity type and the database type.Assume a table like this:
If we query with:
db.Query<TblEntities>().Where(e => e.Enabled)
, the generated SQL effectively becomesSELECT [id], [enabled] FROM tbl_entities WHERE enabled = 1
. If the query were to succeed, the BooleanMapper we wrote will appropriately convert the dataset. But, because theenabled
field is a char, the conversion to '1' fails during the query execution. If the query provider were aware of the registered mappers, the conversion to 'Y' could happen before the query is sent to the database provider.The text was updated successfully, but these errors were encountered: