Browse Source

Add db.IsAnyConnection

pull/4/MERGE
sunkaixuna 3 years ago
parent
commit
24e6800195
  1. 1
      Src/Asp.Net/SqlSugar/Interface/ITenant.cs
  2. 7
      Src/Asp.Net/SqlSugar/SqlSugarClient.cs
  3. 5
      Src/Asp.Net/SqlSugar/SqlSugarScope.cs

1
Src/Asp.Net/SqlSugar/Interface/ITenant.cs

@ -20,6 +20,7 @@ namespace SqlSugar
Task<DbResult<T>> UseTranAsync<T>(Func<T> action, Action<Exception> errorCallBack = null);
void AddConnection(ConnectionConfig connection);
SqlSugarProvider GetConnection(dynamic configId);
bool IsAnyConnection(dynamic configId);
void Close();
void Open();

7
Src/Asp.Net/SqlSugar/SqlSugarClient.cs

@ -610,6 +610,13 @@ namespace SqlSugar
}
return db.Context;
}
public bool IsAnyConnection(dynamic configId)
{
InitTenant();
var db = this._AllClients.FirstOrDefault(it => Convert.ToString(it.ConnectionConfig.ConfigId) == Convert.ToString(configId));
return db != null;
}
public void ChangeDatabase(dynamic configId)
{
configId =Convert.ToString(configId);

5
Src/Asp.Net/SqlSugar/SqlSugarScope.cs

@ -671,5 +671,10 @@ namespace SqlSugar
{
return ScopedContext.UseTranAsync(action, errorCallBack);
}
public bool IsAnyConnection(dynamic configId)
{
return ScopedContext.IsAnyConnection(configId);
}
}
}

Loading…
Cancel
Save