Repository navigation
Reuse compiled queries across tenants - #26282
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Existing custom tenant-dependent query translations could silently reuse tenant-specific compiled SQL across tenants.
1 open finding
What changed in this PR
Updates EF Core compiled-query caching to reuse queries across tenants while retaining filter-state isolation.
Changes:
- Removes tenant IDs from compiled-query cache keys.
- Adds SQLite integration tests for tenant and filter isolation.
- Covers both database-function and standard filter modes.
| File | Description |
|---|---|
QueryCompilationCounter.cs |
Counts query compilations. |
CompiledQueryCacheTestRow.cs |
Defines the test entity. |
CompiledQueryCacheTestModuleWithoutDbFunction.cs |
Configures standard filters. |
CompiledQueryCacheTestModuleBase.cs |
Configures and seeds SQLite tests. |
CompiledQueryCacheTestModule.cs |
Enables database-function filters. |
CompiledQueryCacheTestDbContext.cs |
Defines the test context. |
CompiledQueryCacheTestBase.cs |
Tests cache reuse and data isolation. |
CompiledQueryCache_WithoutDbFunction_Tests.cs |
Runs standard-filter tests. |
CompiledQueryCache_Tests.cs |
Runs database-function tests. |
AbpDbContext.cs |
Removes tenant IDs from cache keys. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
maliming
marked this pull request as draft
October 14, 2026 02:43
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## rel-10.7 #26282 +/- ##
============================================
- Coverage 50.18% 50.05% -0.13%
============================================
Files 3829 3842 +13
Lines 134139 134429 +290
Branches 10172 10199 +27
============================================
- Hits 67311 67285 -26
- Misses 64798 65131 +333
+ Partials 2030 2013 -17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
maliming
marked this pull request as ready for review
October 14, 2026 05:14
ismcagdas
approved these changes
Oct 14, 2026
ismcagdas
added a commit
that referenced
this pull request
Oct 15, 2026
…26284) Related to #26282 With `UseDbFunction`, the soft delete and multi-tenant filter translations treated a missing current DbContext as a disabled filter, so `EF.CompileQuery` and `EF.CompileAsyncQuery` ran without these filters. They now throw an `AbpException`. ABP wraps `IDatabase` and only lets the query that went through the compiled query cache key generator read the current DbContext, so a nested compiled query can't use the outer query's filter state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Resolve #26281
Remove the tenant ID from
AbpDbContext.GetCompiledQueryCacheKey()and keep the data filter states in the key.