- 增加 连接字符串错误时的友好提示;

This commit is contained in:
28810
2019-07-18 11:30:14 +08:00
parent 558d154486
commit de28c38d70
20 changed files with 110 additions and 50 deletions

View File

@ -121,6 +121,13 @@ namespace FreeSql.SqlServer
if (_pool.IsAvailable)
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && obj.Value.Ping() == false)
{
@ -143,6 +150,13 @@ namespace FreeSql.SqlServer
if (_pool.IsAvailable)
{
if (obj.Value == null)
{
if (_pool.SetUnavailable(new Exception("连接字符串错误")) == true)
throw new Exception($"【{this.Name}】连接字符串错误,请检查。");
return;
}
if (obj.Value.State != ConnectionState.Open || DateTime.Now.Subtract(obj.LastReturnTime).TotalSeconds > 60 && (await obj.Value.PingAsync()) == false)
{