Browse Source

-

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
c3d1d8b7db
  1. 13
      OrmTest/UnitTest/ExpressionTest/Where.cs
  2. 8
      SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs

13
OrmTest/UnitTest/ExpressionTest/Where.cs

@ -28,6 +28,7 @@ namespace OrmTest.UnitTest
whereSingle5(); whereSingle5();
whereSingle6(); whereSingle6();
whereSingle7(new Student() { Id = 1 }); whereSingle7(new Student() { Id = 1 });
//whereSingle8(new Student() { Id = 1 });
WhereMultiple1(); WhereMultiple1();
WhereMultiple2(); WhereMultiple2();
@ -150,6 +151,18 @@ namespace OrmTest.UnitTest
new SugarParameter("@Id0",1) new SugarParameter("@Id0",1)
}, "whereSingle7"); }, "whereSingle7");
} }
private void whereSingle8(Student st)
{
Expression<Func<Student, bool>> exp = it => it.Name == null;
ExpressionContext expContext = new ExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "( [Name] is @Id0 )", new List<SugarParameter>() {
new SugarParameter("@Id0",1)
}, "whereSingle8");
}
} }
public class WhereConst public class WhereConst

8
SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs

@ -33,7 +33,8 @@ namespace SqlSugar
var lsrb = !leftIsBinary && rightBinary; var lsrb = !leftIsBinary && rightBinary;
var lbrb = rightBinary && leftIsBinary; var lbrb = rightBinary && leftIsBinary;
var lsbs = !leftIsBinary && !rightBinary; var lsbs = !leftIsBinary && !rightBinary;
if (!base.Context.Result.Contains(ExpressionConst.Format0)) var isBegin = !base.Context.Result.Contains(ExpressionConst.Format0);
if (isBegin)
{ {
base.Context.Result.Append(ExpressionConst.Format3); base.Context.Result.Append(ExpressionConst.Format3);
base.Context.Result.Append(ExpressionConst.Format0); base.Context.Result.Append(ExpressionConst.Format0);
@ -46,11 +47,14 @@ namespace SqlSugar
base.Expression = leftExpression; base.Expression = leftExpression;
base.IsLeft = true; base.IsLeft = true;
base.Start(); base.Start();
base.Context.Result.Replace(ExpressionConst.Format1+parameter.Index,operatorValue);
base.IsLeft = false; base.IsLeft = false;
base.Expression = rightExpression; base.Expression = rightExpression;
base.Start(); base.Start();
base.IsLeft = null; base.IsLeft = null;
base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, operatorValue);
if (lsbs) {
}
base.Context.Result.Append(ExpressionConst.Format4); base.Context.Result.Append(ExpressionConst.Format4);
if (parameter.BaseExpression is BinaryExpression && parameter.IsLeft == true) if (parameter.BaseExpression is BinaryExpression && parameter.IsLeft == true)
{ {

Loading…
Cancel
Save