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++;