Docs
Tenantry CoreAPI reference

ITenantConnectionStringProvider<TKey> interface

Namespace: Tenantry · Package: Tenantry.Core · API reference

Returns a tenant's connection string, as configured by TenantConnectionStringOptions<TKey>.

Registered as a singleton by UseConnectionStrings. It takes the tenant explicitly, for code such as migration runners that visits tenants without making each one current. For the current tenant's connection string, use CurrentTenantConnectionString<TKey>.

Implement it to decorate the default TenantConnectionStringProvider<TKey>, for example to cache.

public interface ITenantConnectionStringProvider<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>

Type parameters

Derived types: TenantConnectionStringProvider<TKey>.

Methods

Get(ITenantDescriptor<TKey>)

Returns tenant's connection string.

string Get(ITenantDescriptor<TKey> tenant)

Parameters:

Returns: string

Exceptions:

GetAsync(ITenantDescriptor<TKey>, CancellationToken)

Returns tenant's connection string, using the asynchronous delegate if configured.

ValueTask<string> GetAsync(ITenantDescriptor<TKey> tenant, CancellationToken cancellationToken = default)

Parameters:

  • tenant ITenantDescriptor<TKey>: The tenant whose connection string to return.
  • cancellationToken CancellationToken: Cancels the lookup.

Returns: ValueTask<string>

Exceptions:

  • InvalidOperationException: The delegate returned an empty value.

On this page