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

VB.NET generated sql WHERE statement issue #31578

Closed
gaglia opened this issue Aug 29, 2023 · 2 comments
Closed

VB.NET generated sql WHERE statement issue #31578

gaglia opened this issue Aug 29, 2023 · 2 comments

Comments

@gaglia
Copy link

gaglia commented Aug 29, 2023

HI,

I'm having a problem using EF Core 7.0.9 in our VB.NET application.

We noticed that LINQ queries are translated differently when called from a C# project or from VB.NET

In VB.NET a SQL query is generated which is in our opinion incorrect, as it generates, for the same LINQ query, many more readings on the database than in C#. (Analysed with SQL profiler from 3 reads to 817)

The same LINQ query in Entity Framework 4.0 (We are converting our application to go from .NET 4.8 and EF 4.0 to .NET 7 and EF Core 7) in our same VB.NET application is generated correctly doing only 3 reads.

Attached I insert an example project where I highlight the problem by showing the sql code generated by EF.

App -> Project C# : All 3 queries are generated successfully with "correct" WHERE filter:

WHERE [g].[CodABI] = @$VB$Local_codABI_0 AND [g].[CodCAB] = @$VB$Local_codCAB_1',N'@$VB$Local_codABI_0 varchar(5),@$VB$Local_codCAB_1 varchar(5)

App.VB -> project in VB.NET: only the last query generates a "correct" sql, instead the other two generate this WHERE filter (causes many more readings on the database):

WHERE (CASE
WHEN [g].[CodABI] = @$VB$Local_codABI_0 THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END & CASE
WHEN [g].[CodCAB] = @
$VB$Local_codCAB_1 THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END) = CAST(1 AS bit)',N'@$VB$Local_codABI_0 varchar(5),@$VB$Local_codCAB_1 varchar(5)

App.VB.Net48 -> project: all 3 queries are generated correctly

In the App project there is the CreateDatabase.sql script to create the sample database on which I generated the tests.

I await your feedback
A thousand thanks

Include provider and version information

EF Core version: 7.0.9
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0
Operating system: Win11
IDE: Visual Studio 2022 17.7.2

EFCoreTest.Solution.zip

@bricelam
Copy link
Contributor

Duplicate of #27202

@bricelam bricelam marked this as a duplicate of #27202 Aug 29, 2023
@gaglia
Copy link
Author

gaglia commented Aug 30, 2023

Thanks so much for the feedback.

I saw that the report has been open for a long time, is there an idea of when the correction and release can be expected?

Because we are facing the migration of our application and we are a little worried by what has emerged from this analysis of the generated sql code.

Thanks again

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

No branches or pull requests

3 participants