Table of Contents

Class TenantContext

Namespace
Compendium.Multitenancy
Assembly
Compendium.Multitenancy.dll

Default implementation of tenant context using AsyncLocal for thread-safe tenant isolation. Maintains tenant information per async context, ensuring proper isolation in concurrent scenarios.

public sealed class TenantContext : ITenantContext
Inheritance
TenantContext
Implements
Inherited Members

Properties

CurrentTenant

Gets the complete information of the current tenant.

public TenantInfo? CurrentTenant { get; }

Property Value

TenantInfo

HasTenant

Gets a value indicating whether a tenant is currently set.

public bool HasTenant { get; }

Property Value

bool

TenantId

Gets the ID of the current tenant.

public string? TenantId { get; }

Property Value

string

TenantName

Gets the name of the current tenant.

public string? TenantName { get; }

Property Value

string

Methods

SetTenant(TenantInfo?)

Sets the current tenant information.

public void SetTenant(TenantInfo? tenant)

Parameters

tenant TenantInfo

The tenant information to set.