AmbientTenantScope
AgentPrism.Abstractions.dllThe ambient passing mechanism for running an operation executed in the background (outside an HTTP request) as a specific tenant.
public static class AmbientTenantScopeInheritance
Section titled “Inheritance”Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”The ITenantContext implementations (the single-tenant
default, the HTTP-based multi-tenant resolver) are singletons and read the
tenant either from a fixed default or from HttpContext. Which
tenant a scheduled job runs for is neither fixed nor lives in an HTTP
context — it is carried inside JobRecord.TenantId. This class
provides a pass-through using the same Threading.AsyncLocal pattern
IHttpContextAccessor uses: while the value is set, both
ITenantContext implementations check it before their own default resolution.
Properties
Section titled “Properties”Current
Section titled “ Current”The current ambient tenant if set right now; null otherwise.
public static string? Current { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”Begin(string)
Section titled “ Begin(string)”Sets the ambient tenant for the duration of the scope.
public static IDisposable Begin(string tenantId)Parameters
Section titled “Parameters”tenantId string
The tenant identifier to use for the duration of the scope.
Returns
Section titled “Returns”An object that restores the previous value when IDisposable.Dispose is called. Nested use is safe.
Exceptions
Section titled “Exceptions”tenantId is empty or whitespace only.