From 53783af1f3f815112b9c922416ce4547d1f76e0c Mon Sep 17 00:00:00 2001 From: "610262374@qq.com" <610262374@qq.com> Date: Wed, 2 Jan 2019 17:53:49 +0800 Subject: [PATCH] Exp to sql bug --- .../SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs index 19a3e547b..66a3f8e53 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs @@ -337,7 +337,8 @@ namespace SqlSugar if (this.Context.Result.IsLockCurrentParameter == false) { var expression = ((UnaryExpression)item).Operand as MemberExpression; - if (expression.Expression == null) + var isDateTimeNow = ((UnaryExpression)item).Operand.ToString() == "DateTime.Now"; + if (expression.Expression == null&&!isDateTimeNow) { this.Context.Result.CurrentParameter = parameter; this.Context.Result.IsLockCurrentParameter = true; @@ -348,7 +349,7 @@ namespace SqlSugar this.Context.Result.Append(this.Context.GetAsString(asName, parameter.CommonTempData.ObjToString())); this.Context.Result.CurrentParameter = null; } - else if (expression.Expression is ConstantExpression) + else if (expression.Expression is ConstantExpression||isDateTimeNow) { string parameterName = this.Context.SqlParameterKeyWord + "constant" + this.Context.ParameterIndex; this.Context.ParameterIndex++;