Synchronization code

This commit is contained in:
sunkaixuan 2023-12-13 14:59:26 +08:00
parent 14d2ff6564
commit 2e1f4d0496
2 changed files with 32 additions and 3 deletions

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
namespace SqlSugar
{
/// <summary>
@ -159,10 +160,22 @@ namespace SqlSugar
{
this.Context.Parameters.Add(new SugarParameter(appendValue, value) { IsArray = true });
}
else if (value!=null&&(value is Enum) &&this.Context?.SugarContext?.Context?.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString == true)
else if (value != null && (value is Enum) && this.Context?.SugarContext?.Context?.CurrentConnectionConfig?.MoreSettings?.TableEnumIsString == true)
{
this.Context.Parameters.Add(new SugarParameter(appendValue,Convert.ToString(value)));
this.Context.Parameters.Add(new SugarParameter(appendValue, Convert.ToString(value)));
}
else if (this.Context
?.SugarContext
?.Context
?.CurrentConnectionConfig
?.MoreSettings
?.IsCorrectErrorSqlParameterName == true
&& columnInfo?.PropertyName != null
&& !columnInfo.PropertyName.IsRegexWNoContainsChinese())
{
appendValue = Context.SqlParameterKeyWord + appendValue.GetHashCode();
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
}
else
{
this.Context.Parameters.Add(new SugarParameter(appendValue, value));

View File

@ -121,7 +121,23 @@ namespace SqlSugar
|| value.ToLower().Contains(left + "create" + right)
|| value.ToLower().Contains(left + "insert" + right);
}
public static bool ContainsChinese(string input)
{
// 正则表达式:匹配包含至少一个中文字符的字符串
string pattern = @"[\u4e00-\u9fa5]";
return Regex.IsMatch(input, pattern);
}
public static bool IsRegexWNoContainsChinese(this string value)
{
if (!ContainsChinese(value)&&Regex.IsMatch(value, @"^\w+$"))
{
return true;
}
else
{
return false;
}
}
public static string ToCheckRegexW(this string value)
{
if (Regex.IsMatch(value,@"^\w+$"))