Browse Source

-

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
001f4d222d
  1. 4
      Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Where.cs
  2. 2
      Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs
  3. 21
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

4
Src/Asp.Net/SqlServerTest/UnitTest/ExpressionTest/Where.cs

@ -400,9 +400,9 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "( CAST( DateName(Year,[Datetime1]) +'-'+ DateName(Month,[Datetime1]) +'-'+ DateName(Day,[Datetime1]) AS DATETIME) > @Date0 )", new List<SugarParameter>()
base.Check(value, pars, "( ( [Bool1]=1 ) AND ( [Bool1]=1 ) )", new List<SugarParameter>()
{
new SugarParameter("@Date0",DateTime.Now.Date),
}, "whereSingle26");
}

2
Src/Asp.Net/SqlSugar/ExpressionsToSql/Common/ExpressionTool.cs

@ -58,7 +58,7 @@ namespace SqlSugar
public static bool IsLogicOperator(string operatorValue)
{
return operatorValue == "&&" || operatorValue == "||";
return operatorValue == "&&" || operatorValue == "||"||operatorValue == "AND" || operatorValue == "OR";
}
public static bool IsLogicOperator(Expression expression)

21
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

@ -27,7 +27,8 @@ namespace SqlSugar
var isDateDate = memberName == "Date" && expression.Expression.Type == UtilConstants.DateType;
var isMemberValue = expression.Expression != null && expression.Expression.NodeType != ExpressionType.Parameter && !isValueBool;
var isSingle = parameter.Context.ResolveType == ResolveExpressType.WhereSingle;
var fieldIsBool = isBool && isLogicOperator;
baseParameter.ChildExpression = expression;
if (isLength)
{
ResolveLength(parameter, isLeft, expression);
@ -56,9 +57,12 @@ namespace SqlSugar
{
ResolveMemberValue(parameter, baseParameter, isLeft, isSetTempData, expression);
}
else if (fieldIsBool)
{
ResolvefieldIsBool(parameter, baseParameter, isLeft, isSetTempData, expression, isSingle);
}
else
{
baseParameter.ChildExpression = expression;
string fieldName = string.Empty;
switch (parameter.Context.ResolveType)
{
@ -165,6 +169,19 @@ namespace SqlSugar
AppendValue(parameter, isLeft, value);
}
}
private void ResolvefieldIsBool(ExpressionParameter parameter, ExpressionParameter baseParameter, bool? isLeft, bool isSetTempData, MemberExpression expression, bool isSingle)
{
var fieldName = GetName(parameter, expression, isLeft, isSingle);
if (isSetTempData)
{
baseParameter.CommonTempData = fieldName;
}
else
{
fieldName = this.Context.DbMehtods.EqualTrue(fieldName.ObjToString());
AppendMember(parameter, isLeft, fieldName);
}
}
private void ResolveDateDate(ExpressionParameter parameter, bool? isLeft, MemberExpression expression)
{

Loading…
Cancel
Save