From c7c96b1efb316c59bb42b9214df72df12c06286f Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 15 Sep 2017 19:23:31 +0800 Subject: [PATCH] - --- .../SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs | 5 +++++ .../SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs | 1 + .../ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs index 835e212bf..820b4cba4 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/DefaultDbMethod.cs @@ -294,5 +294,10 @@ namespace SqlSugar { return string.Join("", strings); } + + public virtual string EqualTrue(string fieldName) + { + return "( " + fieldName + "=1 )"; + } } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs index 88e72ffb3..be0c3b8d6 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/IDbMethods.cs @@ -52,5 +52,6 @@ namespace SqlSugar string False(); string GuidNew(); string MergeString(params string[] strings); + string EqualTrue(string value); } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs index 8c95155f4..f53d9e5fa 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs @@ -127,7 +127,7 @@ namespace SqlSugar fieldName = GetName(parameter, expression, isLeft, isSingle); if (expression.Type == UtilConstants.BoolType && baseParameter.OperatorValue.IsNullOrEmpty()) { - fieldName = "( " + fieldName + "=1 )"; + fieldName = this.Context.DbMehtods.EqualTrue(fieldName); } AppendMember(parameter, isLeft, fieldName); } @@ -148,7 +148,7 @@ namespace SqlSugar string fieldName = GetName(parameter, expression.Expression as MemberExpression, isLeft, isSingle); if (expression.Type == UtilConstants.BoolType && baseParameter.OperatorValue.IsNullOrEmpty()) { - fieldName = "( " + fieldName + "=1 )"; + fieldName = this.Context.DbMehtods.EqualTrue(fieldName); } AppendMember(parameter, isLeft, fieldName); }