mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Synchronization code
This commit is contained in:
parent
57db09375b
commit
1c210f048d
@ -21,6 +21,7 @@ namespace SqlSugar
|
||||
Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null);
|
||||
void AddConnection(ConnectionConfig connection);
|
||||
SqlSugarProvider GetConnection(dynamic configId);
|
||||
void RemoveConnection(string configId);
|
||||
SqlSugarScopeProvider GetConnectionScope(dynamic configId);
|
||||
SqlSugarProvider GetConnectionWithAttr<T>();
|
||||
SqlSugarScopeProvider GetConnectionScopeWithAttr<T>();
|
||||
|
@ -777,6 +777,23 @@ namespace SqlSugar
|
||||
{
|
||||
return new SqlSugarTransaction(this);
|
||||
}
|
||||
public void RemoveConnection(string configId)
|
||||
{
|
||||
var removeData= this._AllClients.FirstOrDefault(it => it.ConnectionConfig.ConfigId.ObjToString()== configId.ObjToString());
|
||||
var currentId= this.CurrentConnectionConfig.ConfigId;
|
||||
if (removeData != null)
|
||||
{
|
||||
if (removeData.Context.Ado.IsAnyTran())
|
||||
{
|
||||
Check.ExceptionEasy("RemoveConnection error has tran",$"删除失败{removeData.ConnectionConfig.ConfigId}存在未提交事务");
|
||||
}
|
||||
else if (removeData.ConnectionConfig.ConfigId.ObjToString()== currentId.ObjToString())
|
||||
{
|
||||
Check.ExceptionEasy("Default ConfigId cannot be deleted", $"默认库不能删除{removeData.ConnectionConfig.ConfigId}");
|
||||
}
|
||||
this._AllClients.Remove(removeData);
|
||||
}
|
||||
}
|
||||
public void AddConnection(ConnectionConfig connection)
|
||||
{
|
||||
Check.ArgumentNullException(connection, "AddConnection.connection can't be null");
|
||||
|
@ -793,5 +793,9 @@ namespace SqlSugar
|
||||
{
|
||||
ScopedContext.Tracking(datas);
|
||||
}
|
||||
public void RemoveConnection(string configId)
|
||||
{
|
||||
ScopedContext.RemoveConnection(configId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user