it=>true Resolve BUG

This commit is contained in:
sunkaixuan
2017-06-04 00:37:30 +08:00
parent 7f4e2d0d7f
commit 9beceaecb6
2 changed files with 35 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ namespace OrmTest.UnitTest
whereSingle7(new Student() { Id = 1 });
whereSingle8(new Student() { Id = 1 });
whereSingle9(new Student() { Id = 1 });
whereSingle10();
whereSingle11();
WhereMultiple1();
WhereMultiple2();
@@ -177,6 +179,34 @@ namespace OrmTest.UnitTest
new SugarParameter("@Name0",null)
}, "whereSingle9");
}
private void whereSingle10()
{
Expression<Func<Student, bool>> exp = it => true;
ExpressionContext expContext = new ExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "( 1 = 1 )", new List<SugarParameter>()
{
}, "whereSingle10");
}
private void whereSingle11()
{
Expression<Func<Student, bool>> exp = it => !true;
ExpressionContext expContext = new ExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "( 1 = 2 )", new List<SugarParameter>()
{
}, "whereSingle11");
}
}
public class WhereConst

View File

@@ -32,6 +32,11 @@ namespace SqlSugar
else
{
var parentIsBinary = parameter.BaseParameter.CurrentExpression is BinaryExpression;
var parentIsRoot = parameter.BaseParameter.CurrentExpression is LambdaExpression;
if (parentIsRoot&& value!=null&&value.GetType()==PubConst.BoolType) {
this.Context.Result.Append(value.ObjToBool()?"( 1 = 1 ) ": "( 1 = 2 ) ");
break;
}
if (value == null && parentIsBinary) {
parameter.BaseParameter.ValueIsNull = true;
value = "NULL";