Browse Source

Exp to sql bug

pull/12/MERGE
610262374@qq.com 6 years ago
parent
commit
53783af1f3
  1. 5
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs

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

Loading…
Cancel
Save