refactor: 引入管理端 DbContext 禁用租户过滤
This commit is contained in:
@@ -13,18 +13,18 @@ public sealed class SqliteTestDatabase : IDisposable
|
||||
{
|
||||
_connection = new SqliteConnection("Filename=:memory:");
|
||||
_connection.Open();
|
||||
Options = new DbContextOptionsBuilder<TakeoutAppDbContext>()
|
||||
Options = new DbContextOptionsBuilder<TakeoutAdminDbContext>()
|
||||
.UseSqlite(_connection)
|
||||
.EnableSensitiveDataLogging()
|
||||
.Options;
|
||||
}
|
||||
|
||||
public DbContextOptions<TakeoutAppDbContext> Options { get; }
|
||||
public DbContextOptions<TakeoutAdminDbContext> Options { get; }
|
||||
|
||||
public TakeoutAppDbContext CreateContext(long tenantId, long userId = 0)
|
||||
public TakeoutAdminDbContext CreateContext(long tenantId, long userId = 0)
|
||||
{
|
||||
EnsureCreated();
|
||||
return new TakeoutAppDbContext(Options, new TestTenantProvider(tenantId), new TestCurrentUserAccessor(userId));
|
||||
return new TakeoutAdminDbContext(Options, new TestTenantProvider(tenantId), new TestCurrentUserAccessor(userId));
|
||||
}
|
||||
|
||||
public void EnsureCreated()
|
||||
@@ -34,7 +34,7 @@ public sealed class SqliteTestDatabase : IDisposable
|
||||
return;
|
||||
}
|
||||
|
||||
using var context = new TakeoutAppDbContext(Options, new TestTenantProvider(1));
|
||||
using var context = new TakeoutAdminDbContext(Options, new TestTenantProvider(1));
|
||||
context.Database.EnsureCreated();
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user