Add db.Ado.IsValidConnection()

This commit is contained in:
sunkaixuan 2022-03-29 18:23:46 +08:00
parent 6c752467a8
commit ed60b3cade
2 changed files with 15 additions and 0 deletions

View File

@ -73,6 +73,20 @@ namespace SqlSugar
#endregion
#region Connection
public virtual bool IsValidConnection()
{
try
{
using (OpenAlways())
{
return true;
}
}
catch (Exception)
{
return false;
}
}
public virtual void Open()
{
CheckConnection();

View File

@ -164,6 +164,7 @@ namespace SqlSugar
void Close();
void Open();
SugarConnection OpenAlways();
bool IsValidConnection();
void CheckConnection();
void BeginTran();