mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
Expression Update
This commit is contained in:
parent
ee999253c2
commit
f68bfac736
@ -21,6 +21,7 @@ namespace OrmTest.UnitTest
|
|||||||
base.Begin();
|
base.Begin();
|
||||||
for (int i = 0; i < base.Count; i++)
|
for (int i = 0; i < base.Count; i++)
|
||||||
{
|
{
|
||||||
|
whereSingle17();
|
||||||
whereSingle16();
|
whereSingle16();
|
||||||
whereSingle15();
|
whereSingle15();
|
||||||
whereSingle1();
|
whereSingle1();
|
||||||
@ -280,6 +281,19 @@ namespace OrmTest.UnitTest
|
|||||||
new SugarParameter("@Const0",dic["key"])
|
new SugarParameter("@Const0",dic["key"])
|
||||||
}, "whereSingle16");
|
}, "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
|
public class WhereConst
|
||||||
|
@ -38,11 +38,19 @@ namespace SqlSugar
|
|||||||
this.Context.Result.Append(value.ObjToBool() ? "( 1 = 1 ) " : "( 1 = 2 ) ");
|
this.Context.Result.Append(value.ObjToBool() ? "( 1 = 1 ) " : "( 1 = 2 ) ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (parentIsBinary && value != null && value.GetType() == PubConst.BoolType && parameter.OppsiteExpression is BinaryExpression)
|
if (parentIsBinary && value != null && value.GetType() == PubConst.BoolType && parameter.BaseExpression != null)
|
||||||
|
{
|
||||||
|
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 ) "));
|
AppendMember(parameter, isLeft, (value.ObjToBool() ? "( 1 = 1 ) " : "( 1 = 2 ) "));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (value == null && parentIsBinary)
|
if (value == null && parentIsBinary)
|
||||||
{
|
{
|
||||||
parameter.BaseParameter.ValueIsNull = true;
|
parameter.BaseParameter.ValueIsNull = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user