Skip to content

Commit e36e13f

Browse files
committed
- 调整 DataType.SqlServer/MySql/PostgreSQL 默认使用 Ado 连接池;
1 parent b99c5f4 commit e36e13f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

FreeSql/FreeSqlBuilder.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public partial class FreeSqlBuilder
2929
bool _isLazyLoading = false;
3030
bool _isExitAutoDisposePool = true;
3131
bool _isQuoteSqlName = true;
32-
bool _isAdoConnectionPool = false;
32+
bool? _isAdoConnectionPool = false;
3333
MappingPriorityType[] _mappingPriorityTypes;
3434
NameConvertType _nameConvertType = NameConvertType.None;
3535
Action<DbCommand> _aopCommandExecuting = null;
@@ -258,16 +258,19 @@ public IFreeSql<TMark> Build<TMark>()
258258
switch (_dataType)
259259
{
260260
case DataType.MySql:
261+
if (_isAdoConnectionPool == null) _isAdoConnectionPool = true;
261262
type = Type.GetType("FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySql")?.MakeGenericType(typeof(TMark)); //MySql.Data.dll
262263
if (type == null) type = Type.GetType("FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector")?.MakeGenericType(typeof(TMark)); //MySqlConnector.dll
263264
if (type == null) throwNotFind("FreeSql.Provider.MySql.dll", "FreeSql.MySql.MySqlProvider<>");
264265
break;
265266
case DataType.SqlServer:
267+
if (_isAdoConnectionPool == null) _isAdoConnectionPool = true;
266268
type = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServer")?.MakeGenericType(typeof(TMark)); //Microsoft.Data.SqlClient.dll
267269
if (type == null) type = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServerForSystem")?.MakeGenericType(typeof(TMark)); //System.Data.SqlClient.dll
268270
if (type == null) throwNotFind("FreeSql.Provider.SqlServer.dll", "FreeSql.SqlServer.SqlServerProvider<>");
269271
break;
270272
case DataType.PostgreSQL:
273+
if (_isAdoConnectionPool == null) _isAdoConnectionPool = true;
271274
type = Type.GetType("FreeSql.PostgreSQL.PostgreSQLProvider`1,FreeSql.Provider.PostgreSQL")?.MakeGenericType(typeof(TMark));
272275
if (type == null) throwNotFind("FreeSql.Provider.PostgreSQL.dll", "FreeSql.PostgreSQL.PostgreSQLProvider<>");
273276
break;
@@ -389,7 +392,7 @@ public IFreeSql<TMark> Build<TMark>()
389392
}
390393
ret = Activator.CreateInstance(type, new object[]
391394
{
392-
_isAdoConnectionPool ? $"AdoConnectionPool,{_masterConnectionString}" : _masterConnectionString,
395+
_isAdoConnectionPool == true ? $"AdoConnectionPool,{_masterConnectionString}" : _masterConnectionString,
393396
_slaveConnectionString,
394397
_connectionFactory
395398
}) as IFreeSql<TMark>;

0 commit comments

Comments
 (0)