Compare commits

...

3 Commits

Author SHA1 Message Date
sunkaixuan
b23e577567 Synchronous code 2025-08-11 15:42:56 +08:00
sunkaixuan
6b4d165181 Update GetCustomTypeByClass 2025-08-11 15:41:51 +08:00
sunkaixuan
5d0ac0f34f Update EscapeLikeValue 2025-08-11 11:51:39 +08:00
5 changed files with 39 additions and 0 deletions

View File

@ -744,6 +744,10 @@ namespace SqlSugar
var newAssembly = new ReflectionInoCacheService().GetOrCreate<Assembly>(key, () => {
try
{
if (string.IsNullOrEmpty(customDllName)&& CustomAssemblies?.Any() == true)
{
customDllName = CustomAssemblies.First().GetName().Name;
}
if (CustomAssemblies?.Any(it => it.FullName.StartsWith(customDllName))==true)
{
return CustomAssemblies?.First(it => it.FullName.StartsWith(customDllName));

View File

@ -1331,6 +1331,10 @@ namespace SqlSugar
{
return UtilMethods.EscapeLikeValue(this.Context, value, wildcard);
}
public string EscapeLikeValue(string value, char [] wildcards)
{
return UtilMethods.EscapeLikeValue(this.Context, value, wildcards);
}
#endregion
}
}

View File

@ -744,6 +744,10 @@ namespace SqlSugar
var newAssembly = new ReflectionInoCacheService().GetOrCreate<Assembly>(key, () => {
try
{
if (string.IsNullOrEmpty(customDllName)&& CustomAssemblies?.Any() == true)
{
customDllName = CustomAssemblies.First().GetName().Name;
}
if (CustomAssemblies?.Any(it => it.FullName.StartsWith(customDllName))==true)
{
return CustomAssemblies?.First(it => it.FullName.StartsWith(customDllName));

View File

@ -52,5 +52,6 @@ namespace SqlSugar
List<T> ToTree<T>(List<T> list, Expression<Func<T, IEnumerable<object>>> childListExpression, Expression<Func<T, object>> parentIdExpression, Expression<Func<T, object>> pkExpression, object rootValue);
KeyValuePair<string, SugarParameter[]> ConditionalModelsToSql(List<IConditionalModel> conditionalModels, int beginIndex = 0);
string EscapeLikeValue(string value, char wildcard = '%');
string EscapeLikeValue(string value,params char[] wildcards);
}
}

View File

@ -82,6 +82,17 @@ namespace SqlSugar
return finalTable;
}
public static string EscapeLikeValue(ISqlSugarClient db, string value,params char[] wildcards)
{
if (wildcards != null)
{
foreach (var item in wildcards)
{
value = EscapeLikeValue(db,value,item);
}
}
return value;
}
public static string EscapeLikeValue(ISqlSugarClient db, string value, char wildcard='%')
{
var dbType = db.CurrentConnectionConfig.DbType;
@ -101,6 +112,21 @@ namespace SqlSugar
case DbType.Access:
case DbType.Odbc:
case DbType.TDSQLForPGODBC:
if (wildcard == ']' || wildcard == '[')
{
var keyLeft2 = "[[]";
var keyRight2 = "[]]";
var leftGuid2 = Guid.NewGuid().ToString();
var rightGuid2 = Guid.NewGuid().ToString();
value = value.Replace(keyLeft2, leftGuid2)
.Replace(keyRight2, rightGuid2);
value = value.Replace(wildcard + "", $"[{wildcard}]");
value = value.Replace(leftGuid2, keyLeft2)
.Replace(rightGuid2,keyRight2);
break;
}
// SQL Server 使用中括号转义 %, _ 等
var keyLeft = "[[]";
var keyRight = "[]]";