Skip to content

EF Core 7 RC produces different translation from EF Core 6 (VB/sqlite) #29222

New issue

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

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

Already on GitHub? # to your account

Closed
ericcan opened this issue Sep 28, 2022 · 2 comments · Fixed by #29223
Closed

EF Core 7 RC produces different translation from EF Core 6 (VB/sqlite) #29222

ericcan opened this issue Sep 28, 2022 · 2 comments · Fixed by #29223

Comments

@ericcan
Copy link

ericcan commented Sep 28, 2022

I have the following LINQ query in my VB code:

        Dim testq = From cf In dbContxt.Cashflows
                    Where cf.Date >= #4/1/2022# And cf.Deposit IsNot Nothing
                    Select cf.Date

It produced the following SQL in EF Core 6.0 (using testq.ToQueryString()):

SELECT "c"."Date"
FROM "Cashflows" AS "c"
WHERE ("c"."Date" >= '2022-04-01 00:00:00') & ("c"."Deposit" IS NOT NULL)

In EF Core 7.0, I am getting a different result, which changes the order of operations of the query:

SELECT "c"."Date"
FROM "Cashflows" AS "c"
WHERE ("c"."Date" >= '2022-04-01 00:00:00') & "c"."Deposit" IS NOT NULL

Note that if I change the query to:

        Dim testq = From cf In dbContxt.Cashflows
                    Where cf.Date >= #4/1/2022# AndAlso cf.Deposit IsNot Nothing
                    Select cf.Date

I get:

SELECT "c"."Date"
FROM "Cashflows" AS "c"
WHERE "c"."Date" >= '2022-04-01 00:00:00' AND "c"."Deposit" IS NOT NULL

This works around the issue, giving me the same results I got in EF Core 6.0

Thanks!

EF Core version: 7.0 RC.1.22426.7
Database provider: Microsoft.EntityFrameworkCore.Sqlite.Core
Target framework: .NET 6.0
Operating system: Windows 11
IDE: Visual Studio 2022 17.3.4

@roji
Copy link
Member

roji commented Sep 28, 2022

This is #26652. We fixed this for 6.0.2 in #26653, but it seems like the merge into main didn't carry over the fix (bcdeef9). I vaguely remember us treating that as a temporary fix (because it added lots of unneeded parentheses), with the 7.0 plan being to do some better/more comprehensive (which became #26652).

We should fix this for 7.0.

@roji roji self-assigned this Sep 28, 2022
roji added a commit to roji/efcore that referenced this issue Sep 28, 2022
roji added a commit to roji/efcore that referenced this issue Sep 28, 2022
roji added a commit to roji/efcore that referenced this issue Sep 29, 2022
@roji roji added this to the 7.0.0 milestone Sep 30, 2022
@ericcan
Copy link
Author

ericcan commented Oct 1, 2022

I wanted to confirm that the latest daily build does, in fact, fix the issue I reported. Thanks for the quick turnaround and the incredible product.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants