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
TKey: The tenant identifier type. SeeITenantDescriptor<TKey>for constraints.
Derived types: TenantConnectionStringProvider<TKey>.
Methods
Get(ITenantDescriptor<TKey>)
Returns tenant's connection string.
string Get(ITenantDescriptor<TKey> tenant)Parameters:
tenantITenantDescriptor<TKey>: The tenant whose connection string to return.
Returns: string
Exceptions:
InvalidOperationException: OnlyTenantConnectionStringOptions<TKey>.GetConnectionStringAsyncis configured (useITenantConnectionStringProvider<TKey>.GetAsync), or the delegate returned an empty value.
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:
tenantITenantDescriptor<TKey>: The tenant whose connection string to return.cancellationTokenCancellationToken: Cancels the lookup.
Returns: ValueTask<string>
Exceptions:
InvalidOperationException: The delegate returned an empty value.