Browse Source

Update Oracle

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
d7c7169fc0
  1. 2
      Src/Asp.Net/OracleTest/Program.cs
  2. 40
      Src/Asp.Net/OracleTest/UnitTest/ExpressionTest/Method.cs
  3. 8
      Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs
  4. 3
      Src/Asp.Net/SqlSugar/SqlSugarClient.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("Oracle developed 75%,to be continued"); //throw new Exception("Oracle developed 75%,to be continued");
// /***Unit Test***/ // /***Unit Test***/
new Select(1).Init(); new Select(1).Init();

40
Src/Asp.Net/OracleTest/UnitTest/ExpressionTest/Method.cs

@ -363,8 +363,8 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle); expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString(); var value = expContext.Result.GetString();
var pars = expContext.Parameters; var pars = expContext.Parameters;
base.Check(value, pars, "((:MethodConst0+1.15740740740741E-08) = :Const3 )", new List<SugarParameter>() { base.Check(value, pars, "((:MethodConst0+(1.15740740740741E-08*:MethodConst1)) = :Const3 )", new List<SugarParameter>() {
new SugarParameter(":Const2",x2) , new SugarParameter(":Const3",x2) ,
new SugarParameter(":MethodConst0",x2), new SugarParameter(":MethodConst0",x2),
new SugarParameter(":MethodConst1",11) new SugarParameter(":MethodConst1",11)
}, "DateAddByType error"); }, "DateAddByType error");
@ -377,41 +377,13 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle); expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString(); var value = expContext.Result.GetString();
var pars = expContext.Parameters; var pars = expContext.Parameters;
base.Check(value, pars, "((:MethodConst0+1) = :Const2 )", new List<SugarParameter>() { base.Check(value, pars, "((:MethodConst0+(1*:MethodConst1)) = :Const2 )", new List<SugarParameter>() {
new SugarParameter(":MethodConst0",x2),new SugarParameter(":MethodConst1",1),new SugarParameter(":Const2",x2) new SugarParameter(":MethodConst0",x2),new SugarParameter(":MethodConst1",1),new SugarParameter(":Const2",x2)
}, "DateAddDay error"); }, "DateAddDay error");
DateAddDay2();
DateAddDay3();
}
private void DateAddDay2()
{
var x2 = DateTime.Now;
Expression<Func<DataTestInfo, bool>> exp = it =>it.Datetime2.Value.AddHours(10) == x2;
OracleExpressionContext expContext = new OracleExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "((\"DATETIME2\"+0.0416666666666667) = :Const2 )", new List<SugarParameter>() {
new SugarParameter(":Const2",x2),
new SugarParameter(":MethodConst1",10)
}, "DateAddDay2 error");
}
private void DateAddDay3()
{
var x2 = DateTime.Now;
Expression<Func<Student, bool>> exp = it => x2.AddHours(1) == x2;
OracleExpressionContext expContext = new OracleExpressionContext();
expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString();
var pars = expContext.Parameters;
base.Check(value, pars, "((:MethodConst1+0.0416666666666667) = :Const3 )", new List<SugarParameter>() {
new SugarParameter(":MethodConst1",x2),new SugarParameter(":MethodConst2",1),new SugarParameter(":Const3",x2)
}, "DateAddDay3 error");
} }
private void DateIsSameByType() private void DateIsSameByType()
{ {
var x2 = DateTime.Now; var x2 = DateTime.Now;
@ -420,7 +392,7 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle); expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString(); var value = expContext.Result.GetString();
var pars = expContext.Parameters; var pars = expContext.Parameters;
base.Check(value, pars, " ROUND(TO_NUMBER(:MethodConst0 - :MethodConst1) * 86400000) ", new List<SugarParameter>() { base.Check(value, pars, " (ROUND(TO_NUMBER(:MethodConst0 - :MethodConst1) * 86400000) = 0) ", new List<SugarParameter>() {
new SugarParameter(":MethodConst0",x2),new SugarParameter(":MethodConst1",x2) new SugarParameter(":MethodConst0",x2),new SugarParameter(":MethodConst1",x2)
}, "DateIsSameByType error"); }, "DateIsSameByType error");
} }
@ -432,7 +404,7 @@ namespace OrmTest.UnitTest
expContext.Resolve(exp, ResolveExpressType.WhereSingle); expContext.Resolve(exp, ResolveExpressType.WhereSingle);
var value = expContext.Result.GetString(); var value = expContext.Result.GetString();
var pars = expContext.Parameters; var pars = expContext.Parameters;
base.Check(value, pars, " ROUND(TO_NUMBER(:MethodConst0 - :MethodConst1)) ", new List<SugarParameter>() { base.Check(value, pars, " (ROUND(TO_NUMBER(:MethodConst0 - :MethodConst1))=0) ", new List<SugarParameter>() {
new SugarParameter(":MethodConst0",x2),new SugarParameter(":MethodConst1",x2) new SugarParameter(":MethodConst0",x2),new SugarParameter(":MethodConst1",x2)
}, "DateIsSameDay error"); }, "DateIsSameDay error");
} }

8
Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs

@ -70,14 +70,14 @@ namespace SqlSugar
time = 1 / 24.0 / 60.0 / 60.0/1000; time = 1 / 24.0 / 60.0 / 60.0/1000;
break; break;
} }
return string.Format("({0}+{1}) ", parameter.MemberName, time); return string.Format("({0}+({1}*{2})) ", parameter.MemberName, time,parameter2.MemberName);
} }
public override string DateAddDay(MethodCallExpressionModel model) public override string DateAddDay(MethodCallExpressionModel model)
{ {
var parameter = model.Args[0]; var parameter = model.Args[0];
var parameter2 = model.Args[1]; var parameter2 = model.Args[1];
return string.Format("({0}+1) ", parameter.MemberName); return string.Format("({0}+(1*{1})) ", parameter.MemberName, parameter2.MemberName);
} }
public override string ToString(MethodCallExpressionModel model) public override string ToString(MethodCallExpressionModel model)
@ -118,7 +118,7 @@ namespace SqlSugar
{ {
var parameter = model.Args[0].MemberName; var parameter = model.Args[0].MemberName;
var parameter2 = model.Args[1].MemberName; var parameter2 = model.Args[1].MemberName;
return string.Format(" ROUND(TO_NUMBER({0} - {1})) ", parameter, parameter2); return string.Format(" (ROUND(TO_NUMBER({0} - {1}))=0) ", parameter, parameter2);
} }
public override string DateIsSameByType(MethodCallExpressionModel model) public override string DateIsSameByType(MethodCallExpressionModel model)
{ {
@ -150,7 +150,7 @@ namespace SqlSugar
time = time * 24 * 60 * 60 * 1000; time = time * 24 * 60 * 60 * 1000;
break; break;
} }
return string.Format(" ROUND(TO_NUMBER({0} - {1}) * {2}) ", parameter, parameter2, time); return string.Format(" (ROUND(TO_NUMBER({0} - {1}) * {2}) = 0) ", parameter, parameter2, time);
} }
} }
} }

3
Src/Asp.Net/SqlSugar/SqlSugarClient.cs

@ -34,7 +34,8 @@ namespace SqlSugar
DependencyManagement.TrySqlite(); DependencyManagement.TrySqlite();
break; break;
case DbType.Oracle: case DbType.Oracle:
throw new Exception("Oracle developed 75%,to be continued"); //throw new Exception("Oracle developed 75%,to be continued");
break;
default: default:
throw new Exception("ConnectionConfig.DbType is null"); throw new Exception("ConnectionConfig.DbType is null");
} }

Loading…
Cancel
Save