mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Expression Update
This commit is contained in:
parent
ee999253c2
commit
f68bfac736
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user