Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mappers are not applied when generating query WHERE clauses #668

Open
bryanboettcher opened this issue Jul 19, 2022 · 0 comments
Open

Mappers are not applied when generating query WHERE clauses #668

bryanboettcher opened this issue Jul 19, 2022 · 0 comments

Comments

@bryanboettcher
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant