MixedStrategyResolver<TKey> class
Namespace: Tenantry.Pro.Strategies.MixedMode · Package: Tenantry.Pro · API reference
Resolves the connection string or schema name for the tenant currently in scope, delegating to the appropriate underlying resolver based on the tenant's assigned strategy.
public sealed class MixedStrategyResolver<TKey> where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters
TKey: The tenant identifier type.
Constructors
MixedStrategyResolver(ITenantContext<TKey>, IOptions<MixedModeOptions<TKey>>, IServiceProvider)
Resolves the connection string or schema name for the tenant currently in scope, delegating to the appropriate underlying resolver based on the tenant's assigned strategy.
public MixedStrategyResolver(ITenantContext<TKey> tenantContext, IOptions<MixedModeOptions<TKey>> options, IServiceProvider serviceProvider)Parameters:
tenantContextITenantContext<TKey>: Supplies the current tenant.optionsIOptions<MixedModeOptions<TKey>>: The mixed-mode options, which choose each tenant's strategy.serviceProviderIServiceProvider: Resolves the chosen strategy's services.
Methods
GetCurrentStrategy()
Returns the TenantStrategy for the tenant currently in scope.
public TenantStrategy GetCurrentStrategy()Returns: TenantStrategy
Exceptions:
TenantNotResolvedException: No tenant in scope.
ResolveConnectionString()
Returns the connection string for the current tenant, or null when the strategy is TenantStrategy.Shared or TenantStrategy.Schema.
public string? ResolveConnectionString()Returns: string
Exceptions:
InvalidOperationException: Strategy isTenantStrategy.DatabasebutUseDatabasePerTenant()was not called.
ResolveSchemaName()
Returns the schema name for the current tenant, or null when the strategy is TenantStrategy.Shared or TenantStrategy.Database.
public string? ResolveSchemaName()Returns: string
Exceptions:
InvalidOperationException: Strategy isTenantStrategy.SchemabutUseSchemaPerTenant()was not called.