diff --git a/Src/Asp.Net/SqlServerTest/Demos/1_Query.cs b/Src/Asp.Net/SqlServerTest/Demos/1_Query.cs index 4002a57f7..acad123de 100644 --- a/Src/Asp.Net/SqlServerTest/Demos/1_Query.cs +++ b/Src/Asp.Net/SqlServerTest/Demos/1_Query.cs @@ -453,7 +453,9 @@ namespace OrmTest.Demo var test51 = db.Queryable().Select(it=>new { x= SqlFunc.ToDate(it.CreateTime).Year+"-" }).ToList(); var test52 = db.Queryable().Select(it => SqlFunc.IsNull(it.CreateTime, SqlFunc.GetDate())).ToList(); var test53 = db.Queryable().Select(it => SqlFunc.IsNull(it.CreateTime, SqlFunc.GetDate())).First(); + var test54 = db.Queryable().Where(it => it.CreateTime == test52.First().Value).ToList(); } + public static void Page() { var db = GetInstance(); diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs index ae8b118b6..94227ef69 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs @@ -32,11 +32,15 @@ namespace SqlSugar { ResolveValueBool(parameter, baseParameter, expression, isLeft, isSingle); } + else if (isValue && expression.Expression != null && expression.Expression is MethodCallExpression) + { + ResolveCallValue(parameter, baseParameter, expression, isLeft, isSetTempData, isSingle); + } else if (isValue) { ResolveValue(parameter, baseParameter, expression, isLeft, isSetTempData, isSingle); } - else if (expression.Expression != null &&expression.Expression.Type==UtilConstants.DateType&&expression is MemberExpression && expression.Expression is MethodCallExpression) + else if (expression.Expression != null && expression.Expression.Type == UtilConstants.DateType && expression is MemberExpression && expression.Expression is MethodCallExpression) { ResolveDateDateByCall(parameter, isLeft, expression); } @@ -193,6 +197,28 @@ namespace SqlSugar } } } + private void ResolveCallValue(ExpressionParameter parameter, ExpressionParameter baseParameter, MemberExpression expression, bool? isLeft, bool isSetTempData, bool isSingle) + { + try + { + baseParameter.ChildExpression = expression; + string fieldName = string.Empty; + if (isSetTempData) + { + var value = ExpressionTool.DynamicInvoke(expression); + baseParameter.CommonTempData = value; + } + else + { + var value = ExpressionTool.DynamicInvoke(expression); + base.AppendValue(parameter, isLeft, value); + } + } + catch + { + Check.Exception(true, "Not Support {0}",expression.ToString()); + } + } private MemberExpression ResolveValue(ExpressionParameter parameter, ExpressionParameter baseParameter, MemberExpression expression, bool? isLeft, bool isSetTempData, bool isSingle) {