22 lines
671 B
C#
22 lines
671 B
C#
|
|
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)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|