You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my web API I have a root tenant, which should be able to access all the data that the tenants have.
Here is some Information about the Project:
.NET 8 Web API
Postgresql
EF Core
Ardialis Specifications
Clean Architecture
Tenants Share the same Database
Finbuckle Multitenancy
Currently I set on each query the IgnoreGlobalQuery() and then set manaully the Filter for the SoftDelete Flag. This approach works if i only load one Entity, the problem is when i try to load child elements, because i'd have to set the SoftDelete Filter for each related Entity or else it displays all the deleted child elements.
So here is my question, is there a way to disable the global filter queries for the tenantId just for one Tenant (in my case the root Tenant)?
In my Optinion a nice way would be to set the filter (or disable) it when the DbContext for the Tenant gets initialized.
Here is my BaseDbContext:
`public abstract class BaseDbContext : MultiTenantIdentityDbContext<ApplicationUser, ApplicationRole, string, IdentityUserClaim, IdentityUserRole, IdentityUserLogin, ApplicationRoleClaim, IdentityUserToken>
{
protected readonly ICurrentUser _currentUser;
private readonly ISerializerService _serializer;
private readonly DatabaseSettings _dbSettings;
private readonly IEventPublisher _events;
// this gets called once per startup
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// SoftDelete FilterQuery gets set for each Entitiy
modelBuilder.AppendGlobalQueryFilter(s => s.DeletedOn == null);
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfigurationsFromAssembly(GetType().Assembly);
}
// this gets called for each Tenant
// here would be a good place to disable to filter queries if the tenant is the root tenant.
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
......
}
....
}`
Thank for your help!
spent already a lot of time trying to figure out what the cleanest way is to achiev this.
The text was updated successfully, but these errors were encountered:
Hi there
In my web API I have a root tenant, which should be able to access all the data that the tenants have.
Here is some Information about the Project:
Currently I set on each query the IgnoreGlobalQuery() and then set manaully the Filter for the SoftDelete Flag. This approach works if i only load one Entity, the problem is when i try to load child elements, because i'd have to set the SoftDelete Filter for each related Entity or else it displays all the deleted child elements.
So here is my question, is there a way to disable the global filter queries for the tenantId just for one Tenant (in my case the root Tenant)?
In my Optinion a nice way would be to set the filter (or disable) it when the DbContext for the Tenant gets initialized.
Here is my BaseDbContext:
`public abstract class BaseDbContext : MultiTenantIdentityDbContext<ApplicationUser, ApplicationRole, string, IdentityUserClaim, IdentityUserRole, IdentityUserLogin, ApplicationRoleClaim, IdentityUserToken>
{
protected readonly ICurrentUser _currentUser;
private readonly ISerializerService _serializer;
private readonly DatabaseSettings _dbSettings;
private readonly IEventPublisher _events;
// this gets called once per startup
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// SoftDelete FilterQuery gets set for each Entitiy
modelBuilder.AppendGlobalQueryFilter(s => s.DeletedOn == null);
....
}`
Thank for your help!
spent already a lot of time trying to figure out what the cleanest way is to achiev this.
The text was updated successfully, but these errors were encountered: