-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Translate ToString on enums with number store types as a CASE/WHEN expression #33635
Comments
This is probably a duplicate of server-side value converters (#10861), since CASE/WHEN is applied in SQL. |
@roji In the second scenario above where I'm looking for a CASE/WHEN expression in the translation of the LINQ query, the #10861 seems like it would fit this issue if I wanted access to the column to ALWAYS be mapped to a CASE/WHEN expression, storing the value as a number in the database and specifying the type on the |
This is a spin-off of #20604, addressing a specific scenario related to the translation of ToString() as a database-side cast.
The goal of #20604 is to translate ToString() as a database-side cast. Let's say I have an entity:
WIth an
OrderStatus
enum:And a DbContext, where the
Status
property is stored in the database as a string:Currently, I can cast the
Status
enum property to a string and call .Contains off of that if I want the ability to search statuses:Which gets translated to the following SQL:
After #20604 is resolved, this will allow the following C# code:
To also translate to the SQL above.
The results of this translated database query match what a client-side evaluation of that LINQ query would return when the
Status
property is stored in the database as a string, but will return different results from a client-side evaluation if the property is stored in the database as a number.In order to align the results of both the client-side evaluation and database query (similar to the reasoning behind #14205), when the
Status
property is stored as a number, I would like to see the following C# code:Translated to the following SQL:
The text was updated successfully, but these errors were encountered: