Class TenantDataFilter
- Namespace
- JD.AI.Core.MultiTenancy
- Assembly
- JD.AI.Core.dll
Provides tenant-scoped data filtering. Services use this to ensure queries only return data belonging to the current tenant.
public sealed class TenantDataFilter
- Inheritance
-
TenantDataFilter
- Inherited Members
Constructors
TenantDataFilter(TenantContext)
public TenantDataFilter(TenantContext context)
Parameters
contextTenantContext
Properties
CurrentTenantId
Current tenant ID, or null if no tenant is resolved.
public string? CurrentTenantId { get; }
Property Value
IsActive
Whether multi-tenant filtering is active.
public bool IsActive { get; }
Property Value
Methods
BelongsToCurrentTenant(string?)
Checks if an item belongs to the current tenant (or is shared).
public bool BelongsToCurrentTenant(string? itemTenantId)
Parameters
itemTenantIdstring
Returns
Filter<T>(IEnumerable<T>, Func<T, string?>)
Filters a collection to only include items belonging to the current tenant. Items with a null tenant ID are included (shared/global items).
public IEnumerable<T> Filter<T>(IEnumerable<T> items, Func<T, string?> tenantIdSelector)
Parameters
itemsIEnumerable<T>tenantIdSelectorFunc<T, string>
Returns
- IEnumerable<T>
Type Parameters
T
GetTenantStamp()
Returns the current tenant ID to stamp on new data entities. Returns null if no tenant context is active.
public string? GetTenantStamp()