-
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
Support different SQL translation when store representation has changed due to value conversion #10434
Comments
Triage: client eval for now. |
Triage: For 2.1, we will:
For 2.1, we will not:
|
See also #11156 |
Warning is done. Clearing milestone to track further improvements. |
What about equality/inequality in Where clause? |
Ran into this running contains on a Int32[] that is value converting from a string field. |
A design proposal is to have two store-side value converters on the type mapping that wouldn't impact the store type used for migrations:
|
Will it be planned for EF 9? |
@voroninp Too early to say yet, but I think it's probably quite unlikely that we'll fully implement this in EF Core 9. |
@ajcvickers , if I wanted to extend that part, where should I look at? In most cases I need translation of comparison operators ( |
@voroninp you'd have to provide more context on exactly which (converted) types you want to add comparison operators to. |
For example we have ints which are time HHmmss, we convert them to our own type |
You'll have to define functions representing operations over RadioTime (e.g. GreaterThan), and then use user-defined function mapping to map them to the SQL operators. |
And in
|
@roji, I need some help: UPD: I got it. It's an expression tree, so it will be Expression.LessThan, so there won't be any call to modelBuilder.HasDbFunction(
typeof(SqlTranslation).GetMethod(
nameof(SqlTranslation.LessThan),
BindingFlags.Public | BindingFlags.Static,
new[] { typeof(DateTimeOffset), typeof(DateTimeOffset) })!)
.HasTranslation(
args => new SqlBinaryExpression(
ExpressionType.LessThan,
args[0],
args[1],
typeof(bool),
new BoolTypeMapping("boolean", DbType.Boolean))); This works, but if I replace with And what type of SQL expression should I use, if I want to define it as an instance function on spot? bool IsOlderThan(Classification classification) => this.Timestamp < classification.Timestamp; |
@voroninp can you please open a separate issue with the precise repro code sample that shows what additional check you're proposing? |
ITNOA Hi, How many votes needed to start implementation of this feature? |
Consider cases like #10427 which involves SQL translations for DateTime calculations. If the property has been mapped to some non-datetime type, then this kind of translation will not work anymore. Instead, query should either:
Probably client eval is what we can realistically do in the short term, but in the future it would be good to have the type mapping/value conversion participate in generating the translations.
The text was updated successfully, but these errors were encountered: