mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-31 15:56:25 +08:00
Update Custom database
This commit is contained in:
parent
a03960ca5f
commit
d003d5e08d
@ -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");
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace SqlSugar
|
||||
{
|
||||
static Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
|
||||
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<T>(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<Assembly>(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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user