Browse Source

-

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
38fccaeb84
  1. 18
      Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs
  2. 3
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs

18
Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Method.cs

@ -760,6 +760,24 @@ namespace OrmTest.UnitTest
{ {
new SugarParameter("@Const0",false) new SugarParameter("@Const0",false)
}, "IIF5 error"); }, "IIF5 error");
IIF6();
}
private void IIF6()
{
var dt = DateTime.Now.Date;
Expression <Func<DataTestInfo, bool>> 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<SugarParameter>()
{
new SugarParameter("@Datetime10",dt),
new SugarParameter("@Const1",dt)
}, "IIF6 error");
} }
} }
} }

3
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs

@ -252,6 +252,9 @@ namespace SqlSugar
protected MethodCallExpressionArgs GetMethodCallArgs(ExpressionParameter parameter, Expression item) protected MethodCallExpressionArgs GetMethodCallArgs(ExpressionParameter parameter, Expression item)
{ {
var newContext = this.Context.GetCopyContext(); 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); newContext.Resolve(item, this.Context.IsJoin ? ResolveExpressType.WhereMultiple : ResolveExpressType.WhereSingle);
this.Context.Index = newContext.Index; this.Context.Index = newContext.Index;
this.Context.ParameterIndex = newContext.ParameterIndex; this.Context.ParameterIndex = newContext.ParameterIndex;

Loading…
Cancel
Save