TTenantScope Class
Establishes the ambient (thread-local) tenant for code that runs outside an HTTP request, such as background jobs and provisioning routines.
Remarks
While a scope is active on a thread, every tenant-routed pool or resolver on that thread sees the scoped tenant: Scope := TTenantScope.Use('acme');.
Scopes nest: when the returned ITenantScope is released, the previous tenant (if any) becomes current again.
TAmbientTenantResolver exposes the ambient tenant as an ITenantResolver.
Syntax
Unit: Aurelius.Tenancy.Context
TTenantScope = class(TObject);
Methods
| Name | Description |
|---|---|
| CurrentTenantId | Returns the id of the ambient tenant of the current thread. |
| HasTenant | Indicates whether an ambient tenant is active on the current thread. |
| Use | Makes the given tenant the ambient tenant of the current thread until the returned scope is released. |