This commit is contained in:
sunkaixuan 2017-01-28 21:52:05 +08:00
parent 10d9e9a180
commit 280d682715
6 changed files with 18 additions and 1 deletions

View File

@ -28,6 +28,7 @@ namespace OrmTest.ExpressionTest
whereSingle5(); whereSingle5();
whereSingle6(); whereSingle6();
WhereMultiple1(); WhereMultiple1();
WhereMultiple2();
} }
base.End("Where Test"); base.End("Where Test");
} }
@ -42,6 +43,22 @@ namespace OrmTest.ExpressionTest
new SugarParameter("@Id0",1) new SugarParameter("@Id0",1)
}, "WhereMultiple1"); }, "WhereMultiple1");
} }
private void WhereMultiple2()
{
string name = "a";
WhereConst.name = "a1";
Expression<Func<Student, bool>> exp = it => (it.Id > 1 && it.Name != name || it.Id == 1) || it.Name == WhereConst.name;
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.WhereMultiple);
expContext.Resolve();
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, " (((( it.Id > @Id0 ) AND ( it.Name <> @Name1 )) OR ( it.Id = @Id2 )) OR ( it.Name = @Name3 ))", new List<SugarParameter>() {
new SugarParameter("@Id0",1),
new SugarParameter("@Name1","a"),
new SugarParameter("@Id2",1),
new SugarParameter("@Name3","a1")
}, "WhereMultiple2");
}
private void whereSingle1() private void whereSingle1()
{ {
Expression<Func<Student, bool>> exp = it => it.Id > 1; Expression<Func<Student, bool>> exp = it => it.Id > 1;

View File

@ -17,7 +17,7 @@ namespace OrmTest
static void Main(string[] args) static void Main(string[] args)
{ {
//Expression To Sql Unit Test //Expression To Sql Unit Test
int eachCount = 1; int eachCount = 1000;
new OrmTest.ExpressionTest.Select(eachCount).Init(); new OrmTest.ExpressionTest.Select(eachCount).Init();
new OrmTest.ExpressionTest.Field(eachCount).Init(); new OrmTest.ExpressionTest.Field(eachCount).Init();
new OrmTest.ExpressionTest.Where(eachCount).Init(); new OrmTest.ExpressionTest.Where(eachCount).Init();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.