Files
Deal/src/core/Deal.Infrastructure/Data/TenantContext.cs
T
Rustam Khalimov e3a2692507 Добить структуру Api, Contracts, SharedKernel и сервисов
Deal.Api/Http -> Services/Models/Extensions; Contracts/Integrations
и SharedKernel/Tenants -> Abstractions/Models; extension-классы
telegram/ml -> Extensions. namespace/using/FQN мигрированы, using
дедуплицированы.
2026-09-11 13:25:18 +03:00

25 lines
729 B
C#

using Deal.SharedKernel.Tenants.Abstractions;
using Deal.SharedKernel.Tenants.Models;
namespace Deal.Infrastructure.Data;
/// <summary>
/// Контекст тенанта на AsyncLocal: пробрасывается через весь запрос.
/// </summary>
public sealed class TenantContext : ITenantContext
{
private static readonly AsyncLocal<TenantId?> Current = new();
public TenantId? TenantId => Current.Value;
public bool HasTenant => Current.Value is not null;
public string? SchemaName => Current.Value?.SchemaName;
/// <inheritdoc />
public void SetTenant(TenantId tenantId) => Current.Value = tenantId;
/// <inheritdoc />
public void Reset() => Current.Value = null;
}