From e36e13f5b2d06b6c2adfc7346b055b243de7c528 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Wed, 15 Nov 2023 14:58:20 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E8=B0=83=E6=95=B4=20DataType.SqlServer/MyS?= =?UTF-8?q?ql/PostgreSQL=20=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8=20Ado=20?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=B1=A0=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql/FreeSqlBuilder.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/FreeSql/FreeSqlBuilder.cs b/FreeSql/FreeSqlBuilder.cs index 6508933f..0142697a 100644 --- a/FreeSql/FreeSqlBuilder.cs +++ b/FreeSql/FreeSqlBuilder.cs @@ -29,7 +29,7 @@ namespace FreeSql bool _isLazyLoading = false; bool _isExitAutoDisposePool = true; bool _isQuoteSqlName = true; - bool _isAdoConnectionPool = false; + bool? _isAdoConnectionPool = false; MappingPriorityType[] _mappingPriorityTypes; NameConvertType _nameConvertType = NameConvertType.None; Action _aopCommandExecuting = null; @@ -258,16 +258,19 @@ namespace FreeSql 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; @@ -389,7 +392,7 @@ namespace FreeSql } ret = Activator.CreateInstance(type, new object[] { - _isAdoConnectionPool ? $"AdoConnectionPool,{_masterConnectionString}" : _masterConnectionString, + _isAdoConnectionPool == true ? $"AdoConnectionPool,{_masterConnectionString}" : _masterConnectionString, _slaveConnectionString, _connectionFactory }) as IFreeSql;