Update ScopedClient

This commit is contained in:
sunkaixuna
2021-07-09 23:45:19 +08:00
parent 2a67e0e8a2
commit 6431ce7d40

View File

@@ -10,13 +10,15 @@ namespace SqlSugar
public class ScopedClient : ISqlSugarClient, ITenant public class ScopedClient : ISqlSugarClient, ITenant
{ {
private SqlSugarClient db; private SqlSugarClient db;
private Action<SqlSugarClient> configAction;
private ScopedClient() private ScopedClient()
{ {
} }
public ScopedClient(SqlSugarClient context) public ScopedClient(SqlSugarClient context,Action<SqlSugarClient> configAction)
{ {
this.db = context; this.db = context;
this.configAction = configAction;
} }
public SqlSugarClient ScopedContext public SqlSugarClient ScopedContext
{ {
@@ -28,6 +30,10 @@ namespace SqlSugar
{ {
CallContextAsync<SqlSugarClient>.SetData(key, new SqlSugarClient(db._allConfigs)); CallContextAsync<SqlSugarClient>.SetData(key, new SqlSugarClient(db._allConfigs));
result = CallContextAsync<SqlSugarClient>.GetData(key); result = CallContextAsync<SqlSugarClient>.GetData(key);
if (this.configAction != null)
{
this.configAction(result);
}
} }
return result; return result;
} }