From 59d05e02bdcb53c30e26e58b0db4d9d45f3fe4bd Mon Sep 17 00:00:00 2001 From: cesnimda Date: Thu, 2 Jul 2026 17:02:46 +0200 Subject: [PATCH] refactor(db): named tenant query filters (RECOMMENDATIONS #6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All 11 tenant isolation filters now use EF 10 named filters ("Tenant") so future filters (soft-delete etc.) can coexist and be selectively ignored per query. Behaviour unchanged — the existing tenant-isolation tests prove it. 55/55 green. Co-Authored-By: Claude Opus 4.8 --- .../Persistence/AppDbContext.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/InboxIntel.Infrastructure/Persistence/AppDbContext.cs b/src/InboxIntel.Infrastructure/Persistence/AppDbContext.cs index e1ac4dc..d09a08b 100644 --- a/src/InboxIntel.Infrastructure/Persistence/AppDbContext.cs +++ b/src/InboxIntel.Infrastructure/Persistence/AppDbContext.cs @@ -47,20 +47,20 @@ public class AppDbContext : DbContext, IAppDbContext // its manual `WHERE UserId ==` clause cannot leak across tenants. Applied // uniformly to all user-scoped entities so EF sees no filtered/unfiltered // navigation mismatch. Bypassed when CurrentUserId is Guid.Empty (workers). - modelBuilder.Entity().HasQueryFilter(e => CurrentUserId == Guid.Empty || e.UserId == CurrentUserId); - modelBuilder.Entity().HasQueryFilter(e => CurrentUserId == Guid.Empty || e.UserId == CurrentUserId); - modelBuilder.Entity().HasQueryFilter(e => CurrentUserId == Guid.Empty || e.UserId == CurrentUserId); - modelBuilder.Entity().HasQueryFilter(e => CurrentUserId == Guid.Empty || e.UserId == CurrentUserId); - modelBuilder.Entity().HasQueryFilter(e => CurrentUserId == Guid.Empty || e.UserId == CurrentUserId); - modelBuilder.Entity