-
Notifications
You must be signed in to change notification settings - Fork 170
Configuring CreateDateBinaryExpression
Behavior
#1473
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
Comments
Hi @JohnYoungers, thank you for bringing up this issue. When encountering a filter like I believe the reason behind this logic is to be able to apply the logical operations on date, such as What issue are you facing with this conversion? Are you experiencing any problems? Could you please provide more details about the specific issue you're encountering? |
No issues from a conversion standpoint, I'm just trying to understand in what scenarios it's needed, and if it's not needed, how I could potentially override it. From a performance standpoint the functionality is detrimental in that indexes wouldn't be utilized efficiently. At least from a MSSQL standpoint, I'm not sure under which scenarios I'd want this behavior, opposed to comparing the values directly |
@JohnYoungers thanks for bringing this to our attention. @xuzhg clarified that this was implemented as a workaround to support comparisons against date-only types. At the time there was the standard Possibly related to:
Regarding how to override it, perhaps you may able to do that with a custom |
I believe when we encounter a filter like this:
myDate le 2025-05-02
The expression per operand will be generated here, which creates a numeric representation:
https://github.com/OData/AspNetCoreOData/blob/main/src/Microsoft.AspNetCore.OData/Query/Expressions/ExpressionBinderHelper.cs#L425-L441
When combined with EFCore, we end up with SQL like so:
I couldn't find an explanation in the code, but is there any reason that couldn't have been a direct comparison (e.g.
[i].[MyDate] <= '2025-05-02'
) in the expression?Would it make sense to toggle such behavior? I don't believe there's an easy way to adjust it on the consuming end
The text was updated successfully, but these errors were encountered: