mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-05 03:17:41 +08:00
Add RemoveConnection
This commit is contained in:
@@ -21,6 +21,7 @@ namespace SqlSugar
|
|||||||
Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null);
|
Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null);
|
||||||
void AddConnection(ConnectionConfig connection);
|
void AddConnection(ConnectionConfig connection);
|
||||||
SqlSugarProvider GetConnection(dynamic configId);
|
SqlSugarProvider GetConnection(dynamic configId);
|
||||||
|
void RemoveConnection(string configId);
|
||||||
SqlSugarScopeProvider GetConnectionScope(dynamic configId);
|
SqlSugarScopeProvider GetConnectionScope(dynamic configId);
|
||||||
SqlSugarProvider GetConnectionWithAttr<T>();
|
SqlSugarProvider GetConnectionWithAttr<T>();
|
||||||
SqlSugarScopeProvider GetConnectionScopeWithAttr<T>();
|
SqlSugarScopeProvider GetConnectionScopeWithAttr<T>();
|
||||||
|
|||||||
@@ -777,6 +777,23 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return new SqlSugarTransaction(this);
|
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)
|
public void AddConnection(ConnectionConfig connection)
|
||||||
{
|
{
|
||||||
Check.ArgumentNullException(connection, "AddConnection.connection can't be null");
|
Check.ArgumentNullException(connection, "AddConnection.connection can't be null");
|
||||||
|
|||||||
@@ -793,5 +793,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
ScopedContext.Tracking(datas);
|
ScopedContext.Tracking(datas);
|
||||||
}
|
}
|
||||||
|
public void RemoveConnection(string configId)
|
||||||
|
{
|
||||||
|
ScopedContext.RemoveConnection(configId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user