Docs
Tenantry CoreAPI reference

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

Derived types: InMemoryTenantStore<TKey>.

Methods

GetAllTenantsAsync(CancellationToken)

Returns all registered tenants.

ValueTask<IReadOnlyList<ITenantDescriptor<TKey>>> GetAllTenantsAsync(CancellationToken cancellationToken = default)

Parameters:

  • cancellationToken CancellationToken: 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:

  • tenantId TKey: The identifier of the tenant to find.
  • cancellationToken CancellationToken: Cancels the lookup.

Returns: ValueTask<ITenantDescriptor<TKey>>

On this page