mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-20 00:44:19 +08:00
Compare commits
3 Commits
f8b242d0d3
...
b23e577567
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b23e577567 | ||
![]() |
6b4d165181 | ||
![]() |
5d0ac0f34f |
@ -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));
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 = "[]]";
|
||||
|
Loading…
Reference in New Issue
Block a user