ITenantStore<TKey> interface
Namespace: Tenantry.Core · Package: Tenantry.Core · API reference
Persists and retrieves tenant definitions. Implement this interface to back tenants with a database, configuration file, or any other store.
A custom store registered via UseStore<TStore>() is scoped, and Tenantry resolves it per operation from a fresh dependency-injection scope (so singleton/background services can read tenants without capturing it). Implementations may therefore depend on scoped services such as a DbContext, but must not assume a singleton lifetime or cache scope-bound state across calls.
public interface ITenantStore<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters
TKey: The tenant identifier type. SeeITenantDescriptor<TKey>for constraints.
Derived types: InMemoryTenantStore<TKey>.
Methods
GetAllTenantsAsync(CancellationToken)
Returns all registered tenants.
ValueTask<IReadOnlyList<ITenantDescriptor<TKey>>> GetAllTenantsAsync(CancellationToken cancellationToken = default)Parameters:
cancellationTokenCancellationToken: Cancels the lookup.
Returns: ValueTask<IReadOnlyList<ITenantDescriptor<TKey>>>
GetTenantAsync(TKey, CancellationToken)
Returns the tenant with the given tenantId, or null if no matching tenant exists.
ValueTask<ITenantDescriptor<TKey>?> GetTenantAsync(TKey tenantId, CancellationToken cancellationToken = default)Parameters:
tenantIdTKey: The identifier of the tenant to find.cancellationTokenCancellationToken: Cancels the lookup.
Returns: ValueTask<ITenantDescriptor<TKey>>
ITenantServiceScope<TKey> interface
A dependency-injection scope with a tenant active, created by ITenantScopeFactory<TKey>tenantry-core-itenantscopefactory.md.
ITenantStoreAccessor<TKey> interface
Reads tenants from the registered ITenantStore<TKey>tenantry-core-itenantstore.md on behalf of singletons, such as hosted services, resolving the store from a fresh dependency-injection scope for each call.