You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
The text was updated successfully, but these errors were encountered: