mh_frame_sps/APT.Infrastructure.EF/TenantModelCacheKeyFactory.cs

22 lines
671 B
C#
Raw Normal View History

2026-04-07 13:47:52 +08:00
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
namespace APT.Infrastructure.EF
{
public sealed class TenantModelCacheKeyFactory<TDbContext> : ModelCacheKeyFactory
where TDbContext : DbContext, ITenantDbContext
{
public override object Create(DbContext context)
{
var dbContext = context as TDbContext;
return new TenantModelCacheKey<TDbContext>(dbContext, dbContext?.Tenant?.Name ?? "no_tenant_identifier");
}
public TenantModelCacheKeyFactory(ModelCacheKeyFactoryDependencies dependencies) : base(dependencies)
{
}
}
}