Docs
Tenantry CoreAPI reference

TenantConnectionStringResolver<TKey> class

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

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

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

public sealed class TenantConnectionStringResolver<TKey> : ITenantConnectionStringResolver<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>

Type parameters

Implements ITenantConnectionStringResolver<TKey>.

Constructors

TenantConnectionStringResolver(ITenantContext<TKey>, TenantConnectionStringOptions<TKey>)

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

public TenantConnectionStringResolver(ITenantContext<TKey> tenantContext, TenantConnectionStringOptions<TKey> options)

Parameters:

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

Methods

Resolve()

Returns the current tenant's connection string.

public string Resolve()

Returns: string

Exceptions:

Resolve(ITenantDescriptor<TKey>)

Returns tenant's connection string.

public string Resolve(ITenantDescriptor<TKey> tenant)

Parameters:

Returns: string

Exceptions:

ResolveAsync(CancellationToken)

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

public ValueTask<string> ResolveAsync(CancellationToken cancellationToken = default)

Parameters:

  • cancellationToken CancellationToken: Cancels the lookup.

Returns: ValueTask<string>

Exceptions:

ResolveAsync(ITenantDescriptor<TKey>, CancellationToken)

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

public ValueTask<string> ResolveAsync(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