Table of Contents

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

context TenantContext

Properties

CurrentTenantId

Current tenant ID, or null if no tenant is resolved.

public string? CurrentTenantId { get; }

Property Value

string

IsActive

Whether multi-tenant filtering is active.

public bool IsActive { get; }

Property Value

bool

Methods

BelongsToCurrentTenant(string?)

Checks if an item belongs to the current tenant (or is shared).

public bool BelongsToCurrentTenant(string? itemTenantId)

Parameters

itemTenantId string

Returns

bool

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

items IEnumerable<T>
tenantIdSelector Func<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()

Returns

string