-
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
Exception in SQL server query in EF Core 6, looks related to HasQueryFilter(), worked in EF Core 5 #26428
Comments
The root cause is the conversion applied to IsDeleted column which is being used in query filter. |
I've also ran into this exact exception with a query like:
removing the include fixed it. Just adding this if it helps but hopefully the fix is coming soon :) |
Workaround: The problem seems to come from the combination of the include statement AND a where clause that filters on a HasConversion property. If you can remove the Where clause from the SQL/server side, or the part of the where clause needing the HasConversion property, but instead apply the where clause after the ToList, then you will get the expected output. For me the cost of the extra rows pulled was minimal, but if your Where clause filters a lot of rows, that wont work for you. Hopefully the real fix will be released soon! |
Is any due date to release those fixes? We using Oracle Boolean Converters, therefore all requests with boolean checks in combination with other fields throws exceptions. Thanks! |
@Doomer3D 6.0.1 is scheduled for release in the coming days. |
FYI for those impacted by this issue: EF Core 6.0.1 is now available from NuGet. |
Problem is fixed, thanks. Update #23884 also, please. |
I've been trying out EF Core 6 against our existing SQL server DB and have come across a strange exception when executing a simple query that includes a navigation between 2 tables in a 1:0/1 relationship. Our tables have a "deleted" (integer) column used for soft delete. I've mapped that to a bool IsDeleted property in my entity classes using the built-in HasConversion() and set up a query filter using HasQueryFilter(s => !s.IsDeleted).
I've put together a single file console app that demonstrates the problem below - zipped project also attached.
EFTest.zip
When I run this against EFCore 6.0.0-rc.2.21480.5, I get a crash: System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. Arg_ParamName_Name'. From the exception, ParamName is "index" and the following is the stack trace:
If I use Nuget to switch to using EFCore 5.0.11, the code executes OK without exception.
A couple of things I've found:
EF Core version: 6.0.0-rc.2.21480.5
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Windows 10 Pro 20H2
IDE: Visual Studio 2022 Version 17.0.0 Preview 6.0
The text was updated successfully, but these errors were encountered: