Expression Bool Bug

This commit is contained in:
610262374@qq.com
2018-12-06 13:19:26 +08:00
parent 49501475fb
commit 4b05418d91
2 changed files with 19 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ namespace OrmTest.UnitTest
base.Begin();
for (int i = 0; i < base.Count; i++)
{
whereSingle31();
whereSingle30();
whereSingle29("22");
whereSingle28();
@@ -71,6 +72,19 @@ namespace OrmTest.UnitTest
}, "whereSingle30");
}
private void whereSingle31()
{
bool? b = false;
Expression<Func<DataTestInfo2, bool>> exp = it => it.Bool2== b.Value;
ExpressionContext expContext = new ExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "( [Bool2] = @Bool20 )", new List<SugarParameter>() {
new SugarParameter("@Bool20",false)
}, "whereSingle30");
}
public string Get28(string a) {
return a + "1";
}

View File

@@ -32,10 +32,14 @@ namespace SqlSugar
{
base.Context.Result.Replace(ExpressionConst.FormatSymbol, ExpressionConst.LeftParenthesis + ExpressionConst.FormatSymbol);
}
if (leftExpression is UnaryExpression&& (leftExpression as UnaryExpression).Operand is UnaryExpression)
if (leftExpression is UnaryExpression && (leftExpression as UnaryExpression).Operand is UnaryExpression&& (leftExpression as UnaryExpression).NodeType != ExpressionType.Not)
{
leftExpression = (leftExpression as UnaryExpression).Operand;
}
if (rightExpression is UnaryExpression&& (rightExpression as UnaryExpression).Operand.Type==UtilConstants.BoolType&& (rightExpression as UnaryExpression).NodeType != ExpressionType.Not)
{
rightExpression = (rightExpression as UnaryExpression).Operand;
}
parameter.LeftExpression = leftExpression;
parameter.RightExpression = rightExpression;
base.Expression = leftExpression;