Expression Update

This commit is contained in:
sunkaixuan 2017-06-28 12:13:32 +08:00
parent ee999253c2
commit f68bfac736
2 changed files with 25 additions and 3 deletions

View File

@ -21,6 +21,7 @@ namespace OrmTest.UnitTest
base.Begin();
for (int i = 0; i < base.Count; i++)
{
whereSingle17();
whereSingle16();
whereSingle15();
whereSingle1();
@ -280,6 +281,19 @@ namespace OrmTest.UnitTest
new SugarParameter("@Const0",dic["key"])
}, "whereSingle16");
}
private void whereSingle17()
{
Expression<Func<DataTestInfo, bool>> exp = it =>true&&it.String.Contains("a");
SqlServerExpressionContext expContext = new SqlServerExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "(( 1 = 1 ) AND ([String] like '%'+@MethodConst1+'%') )", new List<SugarParameter>()
{
new SugarParameter("@MethodConst1","a")
}, "whereSingle17");
}
}
public class WhereConst

View File

@ -38,10 +38,18 @@ namespace SqlSugar
this.Context.Result.Append(value.ObjToBool() ? "( 1 = 1 ) " : "( 1 = 2 ) ");
break;
}
if (parentIsBinary && value != null && value.GetType() == PubConst.BoolType && parameter.OppsiteExpression is BinaryExpression)
if (parentIsBinary && value != null && value.GetType() == PubConst.BoolType && parameter.BaseExpression != null)
{
AppendMember(parameter,isLeft,(value.ObjToBool() ? "( 1 = 1 ) " : "( 1 = 2 ) "));
break;
var isLogicOperator =
parameter.BaseExpression.NodeType == ExpressionType.And ||
parameter.BaseExpression.NodeType == ExpressionType.AndAlso ||
parameter.BaseExpression.NodeType == ExpressionType.Or ||
parameter.BaseExpression.NodeType == ExpressionType.OrElse;
if (isLogicOperator)
{
AppendMember(parameter, isLeft, (value.ObjToBool() ? "( 1 = 1 ) " : "( 1 = 2 ) "));
break;
}
}
if (value == null && parentIsBinary)
{