diff --git a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs index 73466e287..e78dd9351 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs @@ -382,14 +382,15 @@ namespace SqlSugar DependencyManagement.TryOscar(); break; case DbType.MySqlConnector: - InstanceFactory.CustomTypeName = SugarCompatible.IsFramework?"SqlSugar.MySqlConnector": "SqlSugar.MySqlConnectorCore"; + InstanceFactory.CustomDllName = SugarCompatible.IsFramework?"SqlSugar.MySqlConnector": "SqlSugar.MySqlConnectorCore"; break; case DbType.Access: - InstanceFactory.CustomTypeName = SugarCompatible.IsFramework?"SqlSugar.Access": "SqlSugar.AccessCore"; + InstanceFactory.CustomDllName = SugarCompatible.IsFramework?"SqlSugar.Access": "SqlSugar.AccessCore"; break; case DbType.Custom: - Check.Exception(config?.MoreSettings?.CustomNugetDllName == null,ErrorMessage.GetThrowMessage("if DbType is Custmon , ConnectionConfig.MoreSettings.CustomNugetDbName is not null", "DbType是Custom ,而需要设置外部数据库支持dll名称。示例: ConnectionConfig.MoreSettings.CustomNugetDllName=\"SqlSugar.DB2\" , 设置完后我们需要引用SqlSugar.DB2.dll ")); - InstanceFactory.CustomTypeName = config.MoreSettings.CustomNugetDllName; + Check.Exception(InstanceFactory.CustomDbName==null , "DbType.Custom: InstanceFactory.CustomDbName is not null "); + Check.Exception(InstanceFactory.CustomNamespace == null, "DbType.Custom: InstanceFactory.CustomNamespace is not null "); + Check.Exception(InstanceFactory.CustomDllName == null, "DbType.Custom: InstanceFactory.CustomDllName is not null "); break; default: throw new Exception("ConnectionConfig.DbType is null"); diff --git a/Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs b/Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs index bdab95bf4..2ab3dafb7 100644 --- a/Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs +++ b/Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs @@ -13,7 +13,6 @@ namespace SqlSugar public bool DisableNvarchar { get; set; } public bool PgSqlIsAutoToLower = true; public int DefaultCacheDurationInSeconds { get; set; } - public bool? TableEnumIsString { get; set; } - public string CustomNugetDllName { get; set; } + public bool? TableEnumIsString { get; set; } } } diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs index a785b7071..3333eab53 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs @@ -11,7 +11,7 @@ namespace SqlSugar { static Assembly assembly = Assembly.GetExecutingAssembly(); static Dictionary typeCache = new Dictionary(); - public static string CustomTypeName = ""; + public static string CustomDllName = ""; public static string CustomDbName = ""; public static string CustomNamespace = ""; public static bool NoCache = false; @@ -319,10 +319,10 @@ namespace SqlSugar } else { - if (!string.IsNullOrEmpty(CustomTypeName)) - { - type = CustomTypeName; - } + //if (!string.IsNullOrEmpty(CustomDllName)) + //{ + // type = CustomDllName; + //} return UtilConstants.AssemblyName + "." + type + name; } } @@ -412,7 +412,7 @@ namespace SqlSugar { lock (typeCache) { - if (string.IsNullOrEmpty(CustomTypeName)) + if (string.IsNullOrEmpty(CustomDllName)) { type = Type.GetType(className + "`" + types.Length, true).MakeGenericType(types); } @@ -434,7 +434,7 @@ namespace SqlSugar { Type type = null; - if (string.IsNullOrEmpty(CustomTypeName)) + if (string.IsNullOrEmpty(CustomDllName)) { type = Type.GetType(className + "`" + types.Length, true).MakeGenericType(types); } @@ -490,7 +490,7 @@ namespace SqlSugar private static T NoCacheGetCacheInstance(string className) { Type type = null; - if (string.IsNullOrEmpty(CustomTypeName)) + if (string.IsNullOrEmpty(CustomDllName)) { type=assembly.GetType(className); } @@ -504,15 +504,15 @@ namespace SqlSugar internal static Type GetCustomTypeByClass(string className) { - var key = "Assembly_"+ CustomTypeName+assembly.GetHashCode(); + var key = "Assembly_"+ CustomDllName+assembly.GetHashCode(); var newAssembly = new ReflectionInoCacheService().GetOrCreate(key, () => { try { - return Assembly.LoadFrom(CustomTypeName + ".dll"); + return Assembly.LoadFrom(CustomDllName + ".dll"); } catch { - var message = "Not Found " + CustomTypeName + ".dll"; + var message = "Not Found " + CustomDllName + ".dll"; Check.Exception(true, message); return null; }