Table of Contents

Interface ITenantStore

Namespace
Compendium.Multitenancy
Assembly
Compendium.Multitenancy.dll

Defines the contract for storing and retrieving tenant information. Provides persistent storage capabilities for multi-tenant applications.

public interface ITenantStore

Methods

DeleteAsync(string, CancellationToken)

Deletes a tenant from the store.

Task<Result> DeleteAsync(string tenantId, CancellationToken cancellationToken = default)

Parameters

tenantId string

The unique identifier of the tenant to delete.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Result>

A task representing the asynchronous operation.

GetAllAsync(CancellationToken)

Retrieves all tenants from the store.

Task<Result<IEnumerable<TenantInfo>>> GetAllAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Result<IEnumerable<TenantInfo>>>

A task representing the asynchronous operation with all tenants.

GetByIdAsync(string, CancellationToken)

Retrieves a tenant by its unique identifier.

Task<Result<TenantInfo?>> GetByIdAsync(string tenantId, CancellationToken cancellationToken = default)

Parameters

tenantId string

The unique identifier of the tenant.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Result<TenantInfo>>

A task representing the asynchronous operation with the tenant or null if not found.

GetByIdentifierAsync(string, CancellationToken)

Retrieves a tenant by an alternate identifier (e.g., subdomain, custom key).

Task<Result<TenantInfo?>> GetByIdentifierAsync(string identifier, CancellationToken cancellationToken = default)

Parameters

identifier string

The alternate identifier to search for.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Result<TenantInfo>>

A task representing the asynchronous operation with the tenant or null if not found.

SaveAsync(TenantInfo, CancellationToken)

Saves a tenant to the store (create or update).

Task<Result> SaveAsync(TenantInfo tenant, CancellationToken cancellationToken = default)

Parameters

tenant TenantInfo

The tenant information to save.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<Result>

A task representing the asynchronous operation.