Expression !=null BUG

This commit is contained in:
sunkaixuan
2017-06-05 13:10:37 +08:00
parent 2a2923c7a4
commit 7bdad99f49
3 changed files with 18 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ namespace OrmTest.UnitTest
whereSingle10(); whereSingle10();
whereSingle11(); whereSingle11();
whereSingle12(); whereSingle12();
whereSingle13();
WhereMultiple1(); WhereMultiple1();
WhereMultiple2(); WhereMultiple2();
@@ -221,6 +222,19 @@ namespace OrmTest.UnitTest
new SugarParameter("@Bool10",true) new SugarParameter("@Bool10",true)
}, "whereSingle12"); }, "whereSingle12");
} }
private void whereSingle13()
{
Expression<Func<Student, bool>> exp = it => it.Name!=null;
ExpressionContext expContext = new ExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "( [Name] IS NOT NULL )", new List<SugarParameter>()
{
}, "whereSingle13");
}
} }
public class WhereConst public class WhereConst

View File

@@ -15,6 +15,7 @@ namespace SqlSugar
public Expression LeftExpression { get; set; } public Expression LeftExpression { get; set; }
public Expression RightExpression { get; set; } public Expression RightExpression { get; set; }
public Expression CurrentExpression { get; set; } public Expression CurrentExpression { get; set; }
public string OperatorValue { get; set; }
public bool? IsLeft { get; set; } public bool? IsLeft { get; set; }
public int Index { get; set; } public int Index { get; set; }
public bool ValueIsNull { get; set; } public bool ValueIsNull { get; set; }

View File

@@ -18,7 +18,8 @@ namespace SqlSugar
else else
{ {
var expression = this.Expression as BinaryExpression; var expression = this.Expression as BinaryExpression;
var operatorValue = ExpressionTool.GetOperator(expression.NodeType); var operatorValue =parameter.OperatorValue=ExpressionTool.GetOperator(expression.NodeType);
var isEqual = expression.NodeType==ExpressionType.Equal;
var isComparisonOperator = var isComparisonOperator =
expression.NodeType != ExpressionType.And && expression.NodeType != ExpressionType.And &&
expression.NodeType != ExpressionType.AndAlso && expression.NodeType != ExpressionType.AndAlso &&
@@ -53,7 +54,7 @@ namespace SqlSugar
base.IsLeft = null; base.IsLeft = null;
if (lsbs && parameter.ValueIsNull) if (lsbs && parameter.ValueIsNull)
{ {
base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, "IS"); base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, isEqual?"IS":"IS NOT");
} }
else { else {
base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, operatorValue); base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, operatorValue);