diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionConst.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionConst.cs index 89f6a0d72..bbc5f9402 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionConst.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionConst.cs @@ -7,13 +7,13 @@ namespace SqlSugar { internal class ExpressionConst { - public const string Format4 = ")"; - public const string Format3 = "("; - public const string Format0 = "{0}"; - public const string Format1 = "$__$"; public const string Const = "Const"; + public const string FormatSymbol = "{0}"; + public const string RightParenthesis = ")"; + public const string LeftParenthesis = "("; public const string MethodConst = "MethodConst"; public const string SqlFuncFullName = "SqlSugar.SqlFunc"; public const string BinaryFormatString = " ( {0} {1} {2} ) "; + public const string ExpressionReplace = "46450BDC-77B7-4025-B2A6-3F048CA85AD0"; } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs index 10a6ba6b1..0133e1026 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs @@ -113,11 +113,11 @@ namespace SqlSugar Context.ParameterIndex++; if (isLeft == true) { - appendValue += ExpressionConst.Format1 + parameter.BaseParameter.Index; + appendValue += ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index; } - if (this.Context.Result.Contains(ExpressionConst.Format0)) + if (this.Context.Result.Contains(ExpressionConst.FormatSymbol)) { - this.Context.Result.Replace(ExpressionConst.Format0, appendValue.ObjToString()); + this.Context.Result.Replace(ExpressionConst.FormatSymbol, appendValue.ObjToString()); } else { @@ -132,9 +132,9 @@ namespace SqlSugar if (parameter.CurrentExpression is MethodCallExpression) { var appendValue = value; - if (this.Context.Result.Contains(ExpressionConst.Format0)) + if (this.Context.Result.Contains(ExpressionConst.FormatSymbol)) { - this.Context.Result.Replace(ExpressionConst.Format0, appendValue.ObjToString()); + this.Context.Result.Replace(ExpressionConst.FormatSymbol, appendValue.ObjToString()); } else { @@ -159,11 +159,11 @@ namespace SqlSugar appendValue = string.Format(" {0} ", appendValue); if (isLeft == true) { - appendValue += ExpressionConst.Format1 + parameter.BaseParameter.Index; + appendValue += ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index; } - if (this.Context.Result.Contains(ExpressionConst.Format0)) + if (this.Context.Result.Contains(ExpressionConst.FormatSymbol)) { - this.Context.Result.Replace(ExpressionConst.Format0, appendValue); + this.Context.Result.Replace(ExpressionConst.FormatSymbol, appendValue); } else { @@ -186,11 +186,11 @@ namespace SqlSugar appendValue = string.Format(" {0} ", appendValue); if (isLeft == true) { - appendValue += ExpressionConst.Format1 + parameter.BaseParameter.Index; + appendValue += ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index; } - if (this.Context.Result.Contains(ExpressionConst.Format0)) + if (this.Context.Result.Contains(ExpressionConst.FormatSymbol)) { - this.Context.Result.Replace(ExpressionConst.Format0, appendValue); + this.Context.Result.Replace(ExpressionConst.FormatSymbol, appendValue); } else { @@ -209,11 +209,11 @@ namespace SqlSugar appendValue = string.Format(" {0} ", appendValue); if (isLeft == true) { - appendValue += ExpressionConst.Format1 + parameter.BaseParameter.Index; + appendValue += ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index; } - if (this.Context.Result.Contains(ExpressionConst.Format0)) + if (this.Context.Result.Contains(ExpressionConst.FormatSymbol)) { - this.Context.Result.Replace(ExpressionConst.Format0, appendValue); + this.Context.Result.Replace(ExpressionConst.FormatSymbol, appendValue); } else { @@ -226,7 +226,7 @@ namespace SqlSugar { if (isLeft == true) { - this.Context.Result.Append(" " + ExpressionConst.Format1 + parameter.BaseParameter.Index); + this.Context.Result.Append(" " + ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index); } } protected string AppendParameter(object paramterValue) @@ -238,14 +238,14 @@ namespace SqlSugar } protected void AppendNot(object Value) { - var isAppend = !this.Context.Result.Contains(ExpressionConst.Format0); + var isAppend = !this.Context.Result.Contains(ExpressionConst.FormatSymbol); if (isAppend) { this.Context.Result.Append("NOT"); } else { - this.Context.Result.Replace(ExpressionConst.Format0, "NOT"); + this.Context.Result.Replace(ExpressionConst.FormatSymbol, "NOT"); } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs index 40ade6076..d3c422165 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs @@ -22,15 +22,15 @@ namespace SqlSugar var lsrb = !leftIsBinary && rightBinary; var lbrb = rightBinary && leftIsBinary; var lsbs = !leftIsBinary && !rightBinary; - var isAppend = !base.Context.Result.Contains(ExpressionConst.Format0); + var isAppend = !base.Context.Result.Contains(ExpressionConst.FormatSymbol); if (isAppend) { - base.Context.Result.Append(ExpressionConst.Format3); - base.Context.Result.Append(ExpressionConst.Format0); + base.Context.Result.Append(ExpressionConst.LeftParenthesis); + base.Context.Result.Append(ExpressionConst.FormatSymbol); } else { - base.Context.Result.Replace(ExpressionConst.Format0, ExpressionConst.Format3 + ExpressionConst.Format0); + base.Context.Result.Replace(ExpressionConst.FormatSymbol, ExpressionConst.LeftParenthesis + ExpressionConst.FormatSymbol); } parameter.LeftExpression = leftExpression; parameter.RightExpression = rightExpression; @@ -43,18 +43,18 @@ namespace SqlSugar base.IsLeft = null; if (lsbs && parameter.ValueIsNull) { - base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, isEqual ? "IS" : "IS NOT"); - base.Context.Result.Replace(ExpressionConst.Format1 + (parameter.Index+1), isEqual ? "IS" : "IS NOT"); + base.Context.Result.Replace(ExpressionConst.ExpressionReplace + parameter.Index, isEqual ? "IS" : "IS NOT"); + base.Context.Result.Replace(ExpressionConst.ExpressionReplace + (parameter.Index+1), isEqual ? "IS" : "IS NOT"); } else { - base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, operatorValue); - base.Context.Result.Replace(ExpressionConst.Format1 + (parameter.Index + 1), operatorValue); + base.Context.Result.Replace(ExpressionConst.ExpressionReplace + parameter.Index, operatorValue); + base.Context.Result.Replace(ExpressionConst.ExpressionReplace + (parameter.Index + 1), operatorValue); } - base.Context.Result.Append(ExpressionConst.Format4); + base.Context.Result.Append(ExpressionConst.RightParenthesis); if (parameter.BaseExpression is BinaryExpression && parameter.IsLeft == true) { - base.Context.Result.Append(" " + ExpressionConst.Format1 + parameter.BaseParameter.Index + " "); + base.Context.Result.Append(" " + ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index + " "); } } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs index 40e6ee4eb..ba824bee8 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs @@ -176,11 +176,11 @@ namespace SqlSugar fieldName = string.Format(" {0} ", fieldName); if (isLeft == true) { - fieldName += ExpressionConst.Format1 + parameter.BaseParameter.Index; + fieldName += ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index; } - if (base.Context.Result.Contains(ExpressionConst.Format0)) + if (base.Context.Result.Contains(ExpressionConst.FormatSymbol)) { - base.Context.Result.Replace(ExpressionConst.Format0, fieldName); + base.Context.Result.Replace(ExpressionConst.FormatSymbol, fieldName); } else {