Docs
Tenantry CoreAPI reference

TenantConnectionStringProvider<TKey> class

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

The default ITenantConnectionStringProvider<TKey>: calls the configured delegates on every call, without caching.

Public so that other providers (for example a caching one) can wrap it. UseConnectionStrings registers it as a singleton, and forwards ITenantConnectionStringProvider<TKey> to it.

public sealed class TenantConnectionStringProvider<TKey> : ITenantConnectionStringProvider<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>

Type parameters

Implements ITenantConnectionStringProvider<TKey>.

Constructors

TenantConnectionStringProvider(TenantConnectionStringOptions<TKey>)

The default ITenantConnectionStringProvider<TKey>: calls the configured delegates on every call, without caching.

public TenantConnectionStringProvider(TenantConnectionStringOptions<TKey> options)

Parameters:

Public so that other providers (for example a caching one) can wrap it. UseConnectionStrings registers it as a singleton, and forwards ITenantConnectionStringProvider<TKey> to it.

Methods

Get(ITenantDescriptor<TKey>)

Returns tenant's connection string.

public string Get(ITenantDescriptor<TKey> tenant)

Parameters:

Returns: string

Exceptions:

GetAsync(ITenantDescriptor<TKey>, CancellationToken)

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

public 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