零框架多租户设计方案
This commit is contained in:
1 parent
b7caaa2d0c
commit
b4a704526d
42 files changed
+1002
-1
No files matched your search
@@ -0,0 +1,28 @@
|
||||
namespace MultiTenancySample.ServiceDefaults
|
||||
{
|
||||
public class CurrentTenant : ICurrentTenant
|
||||
{
|
||||
public string? TenantId { get; private set; }
|
||||
|
||||
public IDisposable SetTenant(string? tenantId)
|
||||
{
|
||||
string? parentTenantId = TenantId;
|
||||
|
||||
TenantId = tenantId;
|
||||
|
||||
return new DisposeAction(() =>
|
||||
{
|
||||
TenantId = parentTenantId;
|
||||
});
|
||||
}
|
||||
|
||||
public class DisposeAction(Action action) : IDisposable
|
||||
{
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
action();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user