ITenantScope<TKey> interface
Namespace: Tenantry · Package: Tenantry.Core · API reference
A dependency-injection scope with a tenant current, created by ITenantScopeFactory<TKey>.
Disposing the scope (synchronously or asynchronously) disposes its services while the tenant is still current, then restores the tenant that was current when the scope was created. Both forms restore the tenant in the disposing code's own context, so await using is safe in loops and nested scopes.
public interface ITenantScope<TKey> : IServiceScope, IDisposable, IAsyncDisposable where TKey : IEquatable<TKey>, IParsable<TKey>Type parameters
TKey: The tenant identifier type. SeeITenantDescriptor<TKey>for constraints.
Properties
Tenant
The tenant this scope runs as.
ITenantDescriptor<TKey> Tenant { get; }Value: ITenantDescriptor<TKey>
ITenantRegistration interface
A registration that needs the tenant key type, added through ITenantBuilder.Addtenantry-itenantbuilder.md.
ITenantScopeFactory<TKey> interface
Opens tenant scopes for work that runs outside an HTTP request: hosted services, queue consumers, scheduled jobs and console tools.