fix(core): enable SQL Server idle connection recovery
This commit is contained in:
@@ -381,6 +381,15 @@ namespace Lskj.Core
|
||||
{
|
||||
return Internet ? AESUtil.Decrypt(Connection3) : AESUtil.Decrypt(Connection4);
|
||||
}
|
||||
|
||||
private static string EnableSqlServerIdleConnectionResilience(string connectionString)
|
||||
{
|
||||
SqlConnectionStringBuilder builder =
|
||||
new SqlConnectionStringBuilder(connectionString);
|
||||
builder["ConnectRetryCount"] = 1;
|
||||
return builder.ConnectionString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:创建数据库连接</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
@@ -420,6 +429,10 @@ namespace Lskj.Core
|
||||
providerName = "Dm";
|
||||
SqlHelper.ConnectionType = ConnectionType.DmServer;
|
||||
}
|
||||
if (connectionType == ConnectionType.SqlServer)
|
||||
{
|
||||
connStr = EnableSqlServerIdleConnectionResilience(connStr);
|
||||
}
|
||||
SqlHelper.dbFactory = DbProviderFactories.GetFactory(providerName);
|
||||
if (SqlHelper._connection != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user