From 212dfbbaed46dba4ceba12945e83ab7158917f0a Mon Sep 17 00:00:00 2001 From: Zero look <33046233+wch1618@users.noreply.github.com> Date: Thu, 19 Aug 2021 11:39:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=9F=E6=84=8F=E5=8F=AF=E8=83=BD=E6=98=AF?= =?UTF-8?q?=E4=BD=BF=E7=94=A8IsGenericTypeDefinition=E5=8D=B4=E7=94=A8?= =?UTF-8?q?=E4=BA=86IsGenericType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql/FreeSqlBuilder.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/FreeSql/FreeSqlBuilder.cs b/FreeSql/FreeSqlBuilder.cs index 2a15d347..6c8be1d6 100644 --- a/FreeSql/FreeSqlBuilder.cs +++ b/FreeSql/FreeSqlBuilder.cs @@ -171,10 +171,14 @@ namespace FreeSql if (string.IsNullOrEmpty(_masterConnectionString) && _connectionFactory == null) throw new Exception("参数 masterConnectionString 不可为空,请检查 UseConnectionString"); IFreeSql ret = null; var type = _providerType; - if (type?.IsGenericType == true) type = type.MakeGenericType(typeof(TMark)); - if (type == null) + if (type != null) { - Action throwNotFind = (dll, providerType) => throw new Exception($"缺少 FreeSql 数据库实现包:{dll},可前往 nuget 下载;如果存在 {dll} 依然报错(原因是环境问题导致反射不到类型),请在 UseConnectionString/UseConnectionFactory 第三个参数手工传入 typeof({providerType})"); + if (type.IsGenericTypeDefinition) + type = type.MakeGenericType(typeof(TMark)); + } + else + { + Action throwNotFind = (dll, providerType) => throw new Exception($"缺少 FreeSql 数据库实现包:{dll},可前往 nuget 下载;如果存在 {dll} 依然报错(原因是环境问题导致反射不到类型),请在 UseConnectionString/UseConnectionFactory 第三个参数手工传入 typeof({providerType})"); switch (_dataType) { case DataType.MySql: