using Deal.SharedKernel.Tenants.Abstractions; using Deal.SharedKernel.Tenants.Models; namespace Deal.Infrastructure.Data; public sealed class TenantContext : ITenantContext { private static readonly AsyncLocal Current = new(); TenantId? ITenantContext.TenantId => Current.Value; bool ITenantContext.HasTenant => Current.Value is not null; string? ITenantContext.SchemaName => Current.Value?.SchemaName; void ITenantContext.SetTenant(TenantId tenantId) => Current.Value = tenantId; void ITenantContext.Reset() => Current.Value = null; }