diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs index c9463091a..da75a7c1c 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavigatManager.cs @@ -344,6 +344,10 @@ namespace SqlSugar { ids = ids.Select(it => Convert.ToInt64(it)).Cast().ToList(); } + if (navPkColumn?.UnderType?.Name == UtilConstants.StringType.Name) + { + ids = ids.Select(it => it?.ToString()?.Replace(",", "[comma]")).Cast().ToList(); + } conditionalModels.Add((new ConditionalModel() { ConditionalType = ConditionalType.In, @@ -415,6 +419,10 @@ namespace SqlSugar { ids = ids.Select(it => Convert.ToInt64(it)).Cast().ToList(); } + if (navColumn?.UnderType?.Name == UtilConstants.StringType.Name) + { + ids = ids.Select(it => it?.ToString()?.Replace(",", "[comma]")).Cast().ToList(); + } conditionalModels.Add((new ConditionalModel() { ConditionalType = ConditionalType.In, diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider_Condition.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider_Condition.cs index 2976d02f0..53c0b350a 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider_Condition.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider_Condition.cs @@ -265,6 +265,10 @@ namespace SqlSugar { inValue1 = inValue1.Replace("'null'", "null"); } + else if (inValue1.Contains("[comma]")) + { + inValue1 = inValue1.Replace("[comma]", ","); + } else if (inValue1.Contains("[null]")) { inValue1 = inValue1.Replace("[null]", "null"); diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs index 4e1095d4d..a9236cd6d 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/InstanceFactory.cs @@ -11,7 +11,19 @@ namespace SqlSugar { static Assembly assembly = Assembly.GetExecutingAssembly(); static Dictionary typeCache = new Dictionary(); - public static string CustomDllName = ""; + private static string _CustomDllName = ""; + private static List CustomDlls = new List(); + public static string CustomDllName { + get { return _CustomDllName; } + set + { + if (!CustomDlls.Contains(value)) + { + CustomDlls.Add(value); + } + _CustomDllName = value; + } + } public static string CustomDbName = ""; public static string CustomNamespace = ""; public static bool NoCache = false; @@ -605,14 +617,30 @@ namespace SqlSugar internal static Type GetCustomTypeByClass(string className) { - var key = "Assembly_"+ CustomDllName+assembly.GetHashCode(); + Type type = null; + foreach (var item in CustomDlls.AsEnumerable()) + { + if (type == null) + { + type = GetCustomTypeByClass(className, item); + } + if(type != null) + { + break; + } + } + return type; + } + internal static Type GetCustomTypeByClass(string className,string customDllName) + { + var key = "Assembly_" + customDllName + assembly.GetHashCode(); var newAssembly = new ReflectionInoCacheService().GetOrCreate(key, () => { try { var path = Assembly.GetExecutingAssembly().Location; if (path.HasValue()) { - path =System.IO.Path.Combine( System.IO.Path.GetDirectoryName(path), CustomDllName + ".dll"); + path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), customDllName + ".dll"); } if (path.HasValue() && FileHelper.IsExistFile(path)) { @@ -620,15 +648,15 @@ namespace SqlSugar } else { - if (IsWebFrom) + if (IsWebFrom) { - string newpath = (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\"+CustomDllName + ".dll").Replace("file:\\", ""); + string newpath = (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\" + CustomDllName + ".dll").Replace("file:\\", ""); return Assembly.LoadFrom(newpath); } return Assembly.LoadFrom(CustomDllName + ".dll"); } } - catch + catch { var message = "Not Found " + CustomDllName + ".dll"; Check.Exception(true, message); @@ -636,23 +664,38 @@ namespace SqlSugar } }); Type type = newAssembly.GetType(className); - if (type == null) + if (type == null) { - type= assembly.GetType(className); + type = assembly.GetType(className); } return type; } - internal static Type GetCustomTypeByClass(string className) { - var key = "Assembly_" + CustomDllName + assembly.GetHashCode(); + Type type = null; + foreach (var item in CustomDlls.AsEnumerable()) + { + if (type == null) + { + type = GetCustomTypeByClass(className, item); + } + if (type != null) + { + break; + } + } + return type; + } + internal static Type GetCustomTypeByClass(string className,string customDllName) + { + var key = "Assembly_" + customDllName + assembly.GetHashCode(); var newAssembly = new ReflectionInoCacheService().GetOrCreate(key, () => { try { var path = Assembly.GetExecutingAssembly().Location; if (path.HasValue()) { - path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), CustomDllName + ".dll"); + path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), customDllName + ".dll"); } if (path.HasValue() && FileHelper.IsExistFile(path)) { diff --git a/Src/Asp.Net/SqlSugar/Json2Sql/ModelToSql/FuncModelToSql.cs b/Src/Asp.Net/SqlSugar/Json2Sql/ModelToSql/FuncModelToSql.cs index 2861a25e0..cc95c30eb 100644 --- a/Src/Asp.Net/SqlSugar/Json2Sql/ModelToSql/FuncModelToSql.cs +++ b/Src/Asp.Net/SqlSugar/Json2Sql/ModelToSql/FuncModelToSql.cs @@ -69,7 +69,7 @@ namespace SqlSugar .FirstOrDefault(); } private static string GetMethodName(string name, List methods) - { + { var result = methods.FirstOrDefault(it => name.EqualCase("SqlFunc_" + it) || name.EqualCase(it)); Check.Exception(result == null, $" { name } is error "); return result; @@ -92,12 +92,12 @@ namespace SqlSugar string resSql; var args = new List(); foreach (var item in parameters) - { + { var value = GetSqlPart(item, resPars); args.Add(new MethodCallExpressionArgs { MemberName = value, - MemberValue = value, + MemberValue = resPars.FirstOrDefault(it => it.ParameterName == value)?.Value?? value, IsMember = true }); }