Skip to main content
InterviewHubPRO
Section Overview
Q21

Question 21 of 50

Part 2: Entity Framework Core, Security & High-Performance Data (11 - 24)

42%
ASP.NET Core & Web API (50 Qs)•Part 2: Entity Framework Core, Security & High-Performance Data (11 - 24)

What are Global Query Filters and how are they used for Soft Delete & Multi-Tenancy?

junior LevelFormsPerformanceSecurity & Auth

In Simple Words: A query filter applied automatically to all queries for an entity type in OnModelCreating:

  • Soft Delete: modelBuilder.Entity<User>().HasQueryFilter(u => !u.IsDeleted);
  • Any context.Users.ToList() automatically adds WHERE IsDeleted = 0.
  • To bypass when needed: context.Users.IgnoreQueryFilters().ToList().