mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 23:13:42 +08:00
Optimized Code
This commit is contained in:
parent
94a8c30bd6
commit
fca2a2d59d
@ -646,6 +646,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return ScopedContext.Fastest<T>();
|
return ScopedContext.Fastest<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SqlSugarClient GetContext()
|
private SqlSugarClient GetContext()
|
||||||
{
|
{
|
||||||
SqlSugarClient result = null;
|
SqlSugarClient result = null;
|
||||||
@ -669,7 +671,8 @@ namespace SqlSugar
|
|||||||
SqlSugarClient result = CallContextAsync<SqlSugarClient>.GetData(key);
|
SqlSugarClient result = CallContextAsync<SqlSugarClient>.GetData(key);
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
CallContextAsync<SqlSugarClient>.SetData(key, new SqlSugarClient(_configs));
|
List<ConnectionConfig> configList = GetCopyConfigs();
|
||||||
|
CallContextAsync<SqlSugarClient>.SetData(key, new SqlSugarClient(configList));
|
||||||
result = CallContextAsync<SqlSugarClient>.GetData(key);
|
result = CallContextAsync<SqlSugarClient>.GetData(key);
|
||||||
if (this._configAction != null)
|
if (this._configAction != null)
|
||||||
{
|
{
|
||||||
@ -685,7 +688,21 @@ namespace SqlSugar
|
|||||||
SqlSugarClient result = CallContextThread<SqlSugarClient>.GetData(key);
|
SqlSugarClient result = CallContextThread<SqlSugarClient>.GetData(key);
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
CallContextThread<SqlSugarClient>.SetData(key, new SqlSugarClient(_configs.Select(it=>new ConnectionConfig() {
|
List<ConnectionConfig> configList = GetCopyConfigs();
|
||||||
|
CallContextThread<SqlSugarClient>.SetData(key, new SqlSugarClient(configList));
|
||||||
|
result = CallContextThread<SqlSugarClient>.GetData(key);
|
||||||
|
if (this._configAction != null)
|
||||||
|
{
|
||||||
|
this._configAction(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ConnectionConfig> GetCopyConfigs()
|
||||||
|
{
|
||||||
|
return _configs.Select(it => new ConnectionConfig()
|
||||||
|
{
|
||||||
AopEvents = it.AopEvents,
|
AopEvents = it.AopEvents,
|
||||||
ConfigId = it.ConfigId,
|
ConfigId = it.ConfigId,
|
||||||
ConfigureExternalServices = it.ConfigureExternalServices,
|
ConfigureExternalServices = it.ConfigureExternalServices,
|
||||||
@ -695,7 +712,8 @@ namespace SqlSugar
|
|||||||
InitKeyType = it.InitKeyType,
|
InitKeyType = it.InitKeyType,
|
||||||
IsAutoCloseConnection = it.IsAutoCloseConnection,
|
IsAutoCloseConnection = it.IsAutoCloseConnection,
|
||||||
LanguageType = it.LanguageType,
|
LanguageType = it.LanguageType,
|
||||||
MoreSettings=it.MoreSettings==null?null:new ConnMoreSettings() {
|
MoreSettings = it.MoreSettings == null ? null : new ConnMoreSettings()
|
||||||
|
{
|
||||||
DefaultCacheDurationInSeconds = it.MoreSettings.DefaultCacheDurationInSeconds,
|
DefaultCacheDurationInSeconds = it.MoreSettings.DefaultCacheDurationInSeconds,
|
||||||
DisableNvarchar = it.MoreSettings.DisableNvarchar,
|
DisableNvarchar = it.MoreSettings.DisableNvarchar,
|
||||||
PgSqlIsAutoToLower = it.MoreSettings.PgSqlIsAutoToLower,
|
PgSqlIsAutoToLower = it.MoreSettings.PgSqlIsAutoToLower,
|
||||||
@ -703,14 +721,7 @@ namespace SqlSugar
|
|||||||
IsWithNoLockQuery = it.MoreSettings.IsWithNoLockQuery
|
IsWithNoLockQuery = it.MoreSettings.IsWithNoLockQuery
|
||||||
},
|
},
|
||||||
SlaveConnectionConfigs = it.SlaveConnectionConfigs
|
SlaveConnectionConfigs = it.SlaveConnectionConfigs
|
||||||
}).ToList()));
|
}).ToList();
|
||||||
result = CallContextThread<SqlSugarClient>.GetData(key);
|
|
||||||
if (this._configAction != null)
|
|
||||||
{
|
|
||||||
this._configAction(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user