From 483145f98244e05937f16863eb272465014450be Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 30 Jan 2017 18:17:55 +0800 Subject: [PATCH] - --- OrmTest/ExpressionTest/Method.cs | 15 +++++++++++++++ .../ResolveItems/MemberNoExpressionResolve.cs | 13 ++++++++++--- .../ResolveItems/MethodCallExpressionResolve.cs | 1 + 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/OrmTest/ExpressionTest/Method.cs b/OrmTest/ExpressionTest/Method.cs index 22c270857..6605f4285 100644 --- a/OrmTest/ExpressionTest/Method.cs +++ b/OrmTest/ExpressionTest/Method.cs @@ -24,6 +24,7 @@ namespace OrmTest.ExpressionTest StringIsNullOrEmpty(); StringIsNullOrEmpty2(); StringIsNullOrEmpty3(); + StringIsNullOrEmpty4(); } base.End("Method Test"); } @@ -64,6 +65,20 @@ namespace OrmTest.ExpressionTest new SugarParameter("@Id0",2) }, "StringIsNullOrEmpty3"); } + + private void StringIsNullOrEmpty4() + { + WhereConst.name = "xx"; + Expression> exp = it => 2 == it.Id || NBORM.IsNullOrEmpty(WhereConst.name); ; + SqlServerExpressionContext expContext = new SqlServerExpressionContext(exp, ResolveExpressType.WhereSingle); + expContext.Resolve(); + var value = expContext.Result.GetString(); + var pars = expContext.Parameters; + base.Check(value, pars, "(( @Id0 = Id ) OR ( @MethodCost1='' OR @MethodCost1 IS NULL ))", new List() { + new SugarParameter("@MethodCost1","xx"), + new SugarParameter("@Id0",2) + }, "StringIsNullOrEmpty4"); + } } } diff --git a/SqlSugar/ExpressionsToSql/ResolveItems/MemberNoExpressionResolve.cs b/SqlSugar/ExpressionsToSql/ResolveItems/MemberNoExpressionResolve.cs index 041c09251..904d5c0f2 100644 --- a/SqlSugar/ExpressionsToSql/ResolveItems/MemberNoExpressionResolve.cs +++ b/SqlSugar/ExpressionsToSql/ResolveItems/MemberNoExpressionResolve.cs @@ -15,6 +15,8 @@ namespace SqlSugar object value = null; var isField = expression.Member is System.Reflection.FieldInfo; var isProperty = expression.Member is System.Reflection.PropertyInfo; + var baseParameter = parameter.BaseParameter; + var isSetTempData = baseParameter.CommonTempData.IsValuable() && baseParameter.CommonTempData.Equals(CommonTempDataType.ChildNodeSet); if (isField) { value = ExpressionTool.GetFiledValue(expression); @@ -26,10 +28,15 @@ namespace SqlSugar switch (base.Context.ResolveType) { case ResolveExpressType.WhereSingle: - AppendParameter(parameter, isLeft, value); - break; case ResolveExpressType.WhereMultiple: - AppendParameter(parameter, isLeft, value); + if (isSetTempData) + { + baseParameter.CommonTempData = value; + } + else + { + AppendParameter(parameter, isLeft, value); + } break; case ResolveExpressType.SelectSingle: break; diff --git a/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs b/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs index bf01e25b0..8b5ca1a71 100644 --- a/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs +++ b/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs @@ -23,6 +23,7 @@ namespace SqlSugar case ResolveExpressType.WhereMultiple: foreach (var item in args) { + parameter.CommonTempData = CommonTempDataType.ChildNodeSet; base.Expression = item; base.Start(); var methodCallExpressionArgs = new MethodCallExpressionArgs()