Browse Source

Update Oracle

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
ae0d5d41bb
  1. 2
      Src/Asp.Net/OracleTest/Program.cs
  2. 69
      Src/Asp.Net/OracleTest/UnitTest/ExpressionTest/Select.cs

2
Src/Asp.Net/OracleTest/Program.cs

@ -17,7 +17,7 @@ namespace OrmTest
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
// throw new Exception(" to be continued ,It will take another week."); throw new Exception(" to be continued ,It will take another week.");
// /***Unit Test***/ // /***Unit Test***/
new Select(1).Init(); new Select(1).Init();

69
Src/Asp.Net/OracleTest/UnitTest/ExpressionTest/Select.cs

@ -21,7 +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++)
{ {
single(); single();
single2(); single2();
single3(); single3();
single4(); single4();
@ -45,16 +45,16 @@ namespace OrmTest.UnitTest
base.Check( base.Check(
selectorValue, selectorValue,
pars, pars,
@" @constant0 AS ""Name"" , ""it"".""Id"" AS ""Id"" , ""school"".""Id"" AS ""SchoolId"" , ( ""it"".""Id"" + @Id1 ) AS ""TestId"" ", @" :CONSTANT0 AS ""NAME"" , ""IT"".""ID"" AS ""ID"" , ""SCHOOL"".""ID"" AS ""SCHOOLID"" , ( ""IT"".""ID"" + :ID1 ) AS ""TESTID"" ",
new List<SugarParameter>(){ new List<SugarParameter>(){
new SugarParameter("@constant0","a"), new SugarParameter(":constant0","a"),
new SugarParameter("@Id1",1) new SugarParameter(":Id1",1)
}, },
"Select.Multiple Error"); "Select.Multiple Error");
} }
private void Multiple2() private void Multiple2()
{ {
Expression<Func<Student, School, object>> exp = (it, school) => new ViewModelStudent3() { SchoolName=school.Name,Id=SqlFunc.GetSelfAndAutoFill(it.Id) }; Expression<Func<Student, School, object>> exp = (it, school) => new ViewModelStudent3() { SchoolName = school.Name, Id = SqlFunc.GetSelfAndAutoFill(it.Id) };
OracleExpressionContext expContext = new OracleExpressionContext(); OracleExpressionContext expContext = new OracleExpressionContext();
expContext.IsSingle = false; expContext.IsSingle = false;
expContext.Resolve(exp, ResolveExpressType.SelectMultiple); expContext.Resolve(exp, ResolveExpressType.SelectMultiple);
@ -63,9 +63,10 @@ namespace OrmTest.UnitTest
base.Check( base.Check(
selectorValue, selectorValue,
pars, pars,
@" ""school"".""Name"" AS ""SchoolName"" ,it.*", @" ""SCHOOL"".""NAME"" AS ""SCHOOLNAME"" ,IT.*",
new List<SugarParameter>(){ new List<SugarParameter>()
{
}, },
"Select.Multiple Error"); "Select.Multiple Error");
} }
@ -82,16 +83,16 @@ namespace OrmTest.UnitTest
base.Check( base.Check(
selectorValue, selectorValue,
pars, pars,
@" @constant0 AS ""Name"" , ( ""it"".""Id"" / @Id1 ) AS ""Id"" , ""school"".""Id"" AS ""SchoolId"" ", @" :CONSTANT0 AS ""NAME"" , ( ""IT"".""ID"" / :ID1 ) AS ""ID"" , ""SCHOOL"".""ID"" AS ""SCHOOLID"" ",
new List<SugarParameter>(){ new List<SugarParameter>(){
new SugarParameter("@constant0","a"), new SugarParameter(":constant0","a"),
new SugarParameter("@Id1", 2)}, new SugarParameter(":Id1", 2)},
"Select.MultipleDynamic Error"); "Select.MultipleDynamic Error");
} }
private void single() private void single()
{ {
int p = 1; int p = 1;
Expression<Func<Student, object>> exp = it => new Student() { Name = "a", Id = it.Id, SchoolId = p,TestId=it.Id+11 }; Expression<Func<Student, object>> exp = it => new Student() { Name = "a", Id = it.Id, SchoolId = p, TestId = it.Id + 11 };
OracleExpressionContext expContext = new OracleExpressionContext(); OracleExpressionContext expContext = new OracleExpressionContext();
expContext.Resolve(exp, ResolveExpressType.SelectSingle); expContext.Resolve(exp, ResolveExpressType.SelectSingle);
var selectorValue = expContext.Result.GetString(); var selectorValue = expContext.Result.GetString();
@ -99,14 +100,14 @@ namespace OrmTest.UnitTest
base.Check( base.Check(
selectorValue, selectorValue,
pars, pars,
@" @constant0 AS ""Name"" , ""Id"" AS ""Id"" , @constant1 AS ""SchoolId"" , ( ""Id"" + @Id2 ) AS ""TestId"" ", @" :CONSTANT0 AS ""NAME"" , ""ID"" AS ""ID"" , :CONSTANT1 AS ""SCHOOLID"" , ( ""ID"" + :ID2 ) AS ""TESTID"" ",
new List<SugarParameter>(){ new List<SugarParameter>(){
new SugarParameter("@constant0","a"), new SugarParameter(":constant0","a"),
new SugarParameter("@constant1",1), new SugarParameter(":constant1",1),
new SugarParameter("@Id2",11 ) }, new SugarParameter(":Id2",11 ) },
"Select.single Error"); "Select.single Error");
} }
private void single2(int p=1) private void single2(int p = 1)
{ {
Expression<Func<Student, object>> exp = it => new Student() { Name = "a", Id = it.Id, SchoolId = p, TestId = it.Id + 11 }; Expression<Func<Student, object>> exp = it => new Student() { Name = "a", Id = it.Id, SchoolId = p, TestId = it.Id + 11 };
OracleExpressionContext expContext = new OracleExpressionContext(); OracleExpressionContext expContext = new OracleExpressionContext();
@ -116,22 +117,22 @@ namespace OrmTest.UnitTest
base.Check( base.Check(
selectorValue, selectorValue,
pars, pars,
@" @constant0 AS ""Name"" , ""Id"" AS ""Id"" , @constant1 AS ""SchoolId"" , ( ""Id"" + @Id2 ) AS ""TestId"" ", @" :CONSTANT0 AS ""NAME"" , ""ID"" AS ""ID"" , :CONSTANT1 AS ""SCHOOLID"" , ( ""ID"" + :ID2 ) AS ""TESTID"" ",
new List<SugarParameter>(){ new List<SugarParameter>(){
new SugarParameter("@constant0","a"), new SugarParameter(":constant0","a"),
new SugarParameter("@constant1",1), new SugarParameter(":constant1",1),
new SugarParameter("@Id2",11 ) }, new SugarParameter(":Id2",11 ) },
"Select.single Error"); "Select.single Error");
} }
private void single3(int p = 1) private void single3(int p = 1)
{ {
Expression<Func<Student, object>> exp = it => new DataTestInfo() { Datetime1=DateTime.Now, String=it.Name}; Expression<Func<Student, object>> exp = it => new DataTestInfo() { Datetime1 = DateTime.Now, String = it.Name };
OracleExpressionContext expContext = new OracleExpressionContext(); OracleExpressionContext expContext = new OracleExpressionContext();
expContext.Resolve(exp, ResolveExpressType.SelectSingle); expContext.Resolve(exp, ResolveExpressType.SelectSingle);
var selectorValue = expContext.Result.GetString(); var selectorValue = expContext.Result.GetString();
var pars = expContext.Parameters; var pars = expContext.Parameters;
base.Check( base.Check(
@" @constant0 AS ""Datetime1"" , ""Name"" AS ""String"" ", null,selectorValue,null, @" :CONSTANT0 AS ""DATETIME1"" , ""NAME"" AS ""STRING"" ", null, selectorValue, null,
"Select.single3 Error"); "Select.single3 Error");
} }
@ -144,13 +145,13 @@ namespace OrmTest.UnitTest
var selectorValue = expContext.Result.GetString(); var selectorValue = expContext.Result.GetString();
var pars = expContext.Parameters; var pars = expContext.Parameters;
base.Check( base.Check(
@"( ""it"".""CreateTime""<>'' AND ""it"".""CreateTime"" IS NOT NULL )", null, selectorValue, null, @"( ""IT"".""CREATETIME""<>'' AND ""IT"".""CREATETIME"" IS NOT NULL )", null, selectorValue, null,
"Select.single4 Error"); "Select.single4 Error");
} }
private void single5() private void single5()
{ {
var p =(DateTime?) DateTime.Now; var p = (DateTime?)DateTime.Now;
Expression<Func<Student, object>> exp = it => p.HasValue; Expression<Func<Student, object>> exp = it => p.HasValue;
OracleExpressionContext expContext = new OracleExpressionContext(); OracleExpressionContext expContext = new OracleExpressionContext();
expContext.IsSingle = false; expContext.IsSingle = false;
@ -158,16 +159,16 @@ namespace OrmTest.UnitTest
var selectorValue = expContext.Result.GetString(); var selectorValue = expContext.Result.GetString();
var pars = expContext.Parameters; var pars = expContext.Parameters;
base.Check( base.Check(
@"( @constant0<>'' AND @constant0 IS NOT NULL )", new List<SugarParameter>() { @"( :CONSTANT0<>'' AND :CONSTANT0 IS NOT NULL )", new List<SugarParameter>() {
new SugarParameter("@constant0",p) new SugarParameter(":constant0",p)
}, selectorValue, pars, }, selectorValue, pars,
"Select.single4 Error"); "Select.single4 Error");
} }
private void singleDynamic() private void singleDynamic()
{ {
string a = "a"; string a = "a";
Expression<Func<Student, object>> exp = it => new { x = it.Id, shoolid = 1, name = a,p=it.Id*2 }; Expression<Func<Student, object>> exp = it => new { x = it.Id, shoolid = 1, name = a, p = it.Id * 2 };
OracleExpressionContext expContext = new OracleExpressionContext(); OracleExpressionContext expContext = new OracleExpressionContext();
expContext.Resolve(exp, ResolveExpressType.SelectSingle); expContext.Resolve(exp, ResolveExpressType.SelectSingle);
var selectorValue = expContext.Result.GetString(); var selectorValue = expContext.Result.GetString();
@ -175,11 +176,11 @@ namespace OrmTest.UnitTest
base.Check( base.Check(
selectorValue, selectorValue,
pars, pars,
@" ""Id"" AS ""x"" , @constant0 AS ""shoolid"" , @constant1 AS ""name"" , ( ""Id"" * @Id2 ) AS ""p"" ", @" ""ID"" AS ""X"" , :CONSTANT0 AS ""SHOOLID"" , :CONSTANT1 AS ""NAME"" , ( ""ID"" * :ID2 ) AS ""P"" ",
new List<SugarParameter>(){ new List<SugarParameter>(){
new SugarParameter("@constant0",1), new SugarParameter(":constant0",1),
new SugarParameter("@constant1","a"), new SugarParameter(":constant1","a"),
new SugarParameter("@Id2",2)}, new SugarParameter(":Id2",2)},
"Select.singleDynamic Error"); "Select.singleDynamic Error");
} }
} }

Loading…
Cancel
Save