Skip to content

Commit

Permalink
- 调整 DataType.SqlServer/MySql/PostgreSQL 默认使用 Ado 连接池;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Nov 15, 2023
1 parent b99c5f4 commit e36e13f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions FreeSql/FreeSqlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class FreeSqlBuilder
bool _isLazyLoading = false;
bool _isExitAutoDisposePool = true;
bool _isQuoteSqlName = true;
bool _isAdoConnectionPool = false;
bool? _isAdoConnectionPool = false;
MappingPriorityType[] _mappingPriorityTypes;
NameConvertType _nameConvertType = NameConvertType.None;
Action<DbCommand> _aopCommandExecuting = null;
Expand Down Expand Up @@ -258,16 +258,19 @@ public IFreeSql<TMark> Build<TMark>()
switch (_dataType)
{
case DataType.MySql:
if (_isAdoConnectionPool == null) _isAdoConnectionPool = true;
type = Type.GetType("FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySql")?.MakeGenericType(typeof(TMark)); //MySql.Data.dll
if (type == null) type = Type.GetType("FreeSql.MySql.MySqlProvider`1,FreeSql.Provider.MySqlConnector")?.MakeGenericType(typeof(TMark)); //MySqlConnector.dll
if (type == null) throwNotFind("FreeSql.Provider.MySql.dll", "FreeSql.MySql.MySqlProvider<>");
break;
case DataType.SqlServer:
if (_isAdoConnectionPool == null) _isAdoConnectionPool = true;
type = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServer")?.MakeGenericType(typeof(TMark)); //Microsoft.Data.SqlClient.dll
if (type == null) type = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServerForSystem")?.MakeGenericType(typeof(TMark)); //System.Data.SqlClient.dll
if (type == null) throwNotFind("FreeSql.Provider.SqlServer.dll", "FreeSql.SqlServer.SqlServerProvider<>");
break;
case DataType.PostgreSQL:
if (_isAdoConnectionPool == null) _isAdoConnectionPool = true;
type = Type.GetType("FreeSql.PostgreSQL.PostgreSQLProvider`1,FreeSql.Provider.PostgreSQL")?.MakeGenericType(typeof(TMark));
if (type == null) throwNotFind("FreeSql.Provider.PostgreSQL.dll", "FreeSql.PostgreSQL.PostgreSQLProvider<>");
break;
Expand Down Expand Up @@ -389,7 +392,7 @@ public IFreeSql<TMark> Build<TMark>()
}
ret = Activator.CreateInstance(type, new object[]
{
_isAdoConnectionPool ? $"AdoConnectionPool,{_masterConnectionString}" : _masterConnectionString,
_isAdoConnectionPool == true ? $"AdoConnectionPool,{_masterConnectionString}" : _masterConnectionString,
_slaveConnectionString,
_connectionFactory
}) as IFreeSql<TMark>;
Expand Down

0 comments on commit e36e13f

Please sign in to comment.