Interface ITenantScope
- Namespace
- Cratis.Arc.Tenancy
- Assembly
- Cratis.Arc.Core.dll
Defines an explicit tenant boundary for the current asynchronous execution flow.
public interface ITenantScope
- Extension Methods
Methods
Begin(TenantId)
Selects a tenant until the returned scope is disposed, including during an HTTP request.
IDisposable Begin(TenantId tenant)
Parameters
tenantTenantIdThe tenant to select.
Returns
- IDisposable
A scope that restores the previously selected tenant on disposal. Disposal is idempotent; disposing an outer scope before an inner scope leaves the inner tenant selected, then restores resolution when the inner scope ends.
Remarks
A selected tenant takes precedence over the configured resolver, but does not authorize access to that tenant. Resolve tenant-scoped dependencies in a DI scope created after beginning this tenant scope.
Exceptions
- ArgumentNullException
The tenant is null.
- ArgumentException
The tenant ID is empty or whitespace.
- ExplicitTenantScopeRequiresArcAccessor
The effective tenant accessor does not support explicit scopes (raised when resolving this service).