-
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
Combination of IgnoreQueryFilters with Max throws exception. #34682
Comments
What's keyName? As always, a single line of code does not provide enough information to reproduce the issue. Please submit a minimal, runnable code sample. |
var max = dbSet.IgnoreQueryFilters().AsNoTracking().Max(s => EF.Property(s, keyName)); try this, might works |
Please take the time to submit a verified, minimal console program. |
I have a dbset and and I need to find max id in table, including soft deleted entries.
For Max I need to the Max(this IQueryable source, string predicate, params object?[] args)
If I don't use IgnoreQueryFilters I am getting the last not soft-deleted entry, as the true soft-deleted entry is excluded from setting HasQueryFilter(x => !x.IsDeleted) in the OnModelCreating sub of ModelBuilder.
When I use IgnoreQueryFilters then I get an exception.
The exception I am getting is the following
EF Core version:
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL
Target framework: .NET 8.0
Operating system: Windows 11 Enterprise 22H2 22621.4169
IDE: Visual Studio 2022 17.11.3
The text was updated successfully, but these errors were encountered: