diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs b/Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs index d5699f833..813c44807 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs @@ -760,6 +760,24 @@ namespace OrmTest.UnitTest { new SugarParameter("@Const0",false) }, "IIF5 error"); + IIF6(); + } + + private void IIF6() + { + var dt = DateTime.Now.Date; + Expression > exp = it => SqlFunc.IIF(dt == it.Datetime1,it.Datetime1, it.Datetime1) == dt; + SqlServerExpressionContext expContext = new SqlServerExpressionContext(); + expContext.MappingColumns = new MappingColumnList(); + expContext.MappingColumns.Add("Datetime1", "Datetime2", "DataTestInfo"); + expContext.Resolve(exp, ResolveExpressType.WhereSingle); + var value = expContext.Result.GetString(); + var pars = expContext.Parameters; + base.Check(value, pars, "(( CASE WHEN ( @Datetime10 = [Datetime2] ) THEN [Datetime2] ELSE [Datetime2] END ) = @Const1 )", new List() + { + new SugarParameter("@Datetime10",dt), + new SugarParameter("@Const1",dt) + }, "IIF6 error"); } } } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs index 135f36f26..10a6ba6b1 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs @@ -252,6 +252,9 @@ namespace SqlSugar protected MethodCallExpressionArgs GetMethodCallArgs(ExpressionParameter parameter, Expression item) { var newContext = this.Context.GetCopyContext(); + newContext.MappingColumns = this.Context.MappingColumns; + newContext.MappingTables = this.Context.MappingTables; + newContext.IgnoreComumnList = this.Context.IgnoreComumnList; newContext.Resolve(item, this.Context.IsJoin ? ResolveExpressType.WhereMultiple : ResolveExpressType.WhereSingle); this.Context.Index = newContext.Index; this.Context.ParameterIndex = newContext.ParameterIndex;