Browse Source

Update Oracle

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
361cd1fe4a
  1. 10
      Src/Asp.Net/OracleTest/Demos/1_Query.cs
  2. 2
      Src/Asp.Net/OracleTest/Demos/DemoBase.cs
  3. 4
      Src/Asp.Net/OracleTest/Program.cs
  4. 4
      Src/Asp.Net/OracleTest/UnitTest/ExpressionTest/Method.cs
  5. 2
      Src/Asp.Net/SqlSugar/Realization/Oracle/OracleProvider.cs
  6. 34
      Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleExpressionContext.cs
  7. 2
      Src/Asp.Net/SqlSugar/SqlSugarClient.cs

10
Src/Asp.Net/OracleTest/Demos/1_Query.cs

@ -144,9 +144,9 @@ namespace OrmTest.Demo
{ {
var db = GetInstance(); var db = GetInstance();
db.Ado.BeginTran(); db.Ado.BeginTran();
var t1 = db.Ado.SqlQuery<string>("select 'a'"); var t1 = db.Ado.SqlQuery<string>("select 'a' from dual");
var t2 = db.Ado.GetInt("select 1"); var t2 = db.Ado.GetInt("select 1 from dual");
var t3 = db.Ado.GetDataTable("select 1 as id"); var t3 = db.Ado.GetDataTable("select 1 as id from dual");
db.Ado.CommitTran(); db.Ado.CommitTran();
//more //more
//db.Ado.GetXXX... //db.Ado.GetXXX...
@ -179,7 +179,7 @@ namespace OrmTest.Demo
var between = db.Queryable<Student>().Where(it => SqlFunc.Between(it.Id, 1, 20)).ToList(); var between = db.Queryable<Student>().Where(it => SqlFunc.Between(it.Id, 1, 20)).ToList();
var getTodayList = db.Queryable<Student>().Where(it => SqlFunc.DateIsSame(it.CreateTime, DateTime.Now)).ToList(); // var getTodayList = db.Queryable<Student>().Where(it => SqlFunc.DateIsSame(it.CreateTime, DateTime.Now)).ToList();
var joinSql = db.Queryable("student", "s").OrderBy("id").Select("id,name").ToPageList(1, 2); var joinSql = db.Queryable("student", "s").OrderBy("id").Select("id,name").ToPageList(1, 2);
} }
@ -359,7 +359,7 @@ namespace OrmTest.Demo
var db = GetInstance(); var db = GetInstance();
var join3 = db.Queryable("Student", "st") var join3 = db.Queryable("Student", "st")
.AddJoinInfo("School", "sh", "sh.id=st.schoolid") .AddJoinInfo("School", "sh", "sh.id=st.schoolid")
.Where("st.id>@id") .Where("st.id>:id")
.AddParameters(new { id = 1 }) .AddParameters(new { id = 1 })
.Select("st.*").ToList(); .Select("st.*").ToList();
//SELECT st.* FROM [Student] st Left JOIN School sh ON sh.id=st.schoolid WHERE st.id>@id //SELECT st.* FROM [Student] st Left JOIN School sh ON sh.id=st.schoolid WHERE st.id>@id

2
Src/Asp.Net/OracleTest/Demos/DemoBase.cs

@ -14,7 +14,7 @@ namespace OrmTest.Demo
db.Ado.IsEnableLogEvent = true; db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) => db.Ado.LogEventStarting = (sql, pars) =>
{ {
Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars)); Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it=>it.ParameterName,it=>it.Value)));
Console.WriteLine(); Console.WriteLine();
}; };
return db; return db;

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

@ -23,7 +23,7 @@ namespace OrmTest
new Select(1).Init(); new Select(1).Init();
new Field(1).Init(); new Field(1).Init();
// new Where(1).Init(); // new Where(1).Init();
new Method(1).Init(); //new Method(1).Init();
//new JoinQuery(1).Init(); //new JoinQuery(1).Init();
//new SingleQuery(1).Init(); //new SingleQuery(1).Init();
//new SelectQuery(1).Init(); //new SelectQuery(1).Init();
@ -38,7 +38,7 @@ namespace OrmTest
//new SqlSugarPerformance(100).Select(); //new SqlSugarPerformance(100).Select();
/***Demo***/ /***Demo***/
//OrmTest.Demo.Query.Init(); OrmTest.Demo.Query.Init();
//OrmTest.Demo.Insert.Init(); //OrmTest.Demo.Insert.Init();
//OrmTest.Demo.Delete.Init(); //OrmTest.Demo.Delete.Init();
//OrmTest.Demo.Update.Init(); //OrmTest.Demo.Update.Init();

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

@ -54,8 +54,8 @@ namespace OrmTest.UnitTest
Between(); Between();
Equals(); Equals();
Equals_2(); Equals_2();
DateIsSameByDay(); //DateIsSameByDay();
DateIsSameByType(); //DateIsSameByType();
DateAddDay(); DateAddDay();
DateAddByType(); DateAddByType();
DateValue(); DateValue();

2
Src/Asp.Net/SqlSugar/Realization/Oracle/OracleProvider.cs

@ -60,7 +60,7 @@ namespace SqlSugar
} }
public override IDataAdapter GetAdapter() public override IDataAdapter GetAdapter()
{ {
return new SqlDataAdapter(); return new OracleDataAdapter();
} }
public override IDbCommand GetCommand(string sql, SugarParameter[] parameters) public override IDbCommand GetCommand(string sql, SugarParameter[] parameters)
{ {

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

@ -145,41 +145,11 @@ namespace SqlSugar
} }
public override string DateIsSameDay(MethodCallExpressionModel model) public override string DateIsSameDay(MethodCallExpressionModel model)
{ {
var parameter = model.Args[0].MemberName; throw new NotSupportedException("Oracle NotSupportedException DateIsSameDay");
var parameter2 = model.Args[1].MemberName;
return string.Format(" (ROUND(TO_NUMBER({0} - {1}))=0) ", parameter, parameter2);
} }
public override string DateIsSameByType(MethodCallExpressionModel model) public override string DateIsSameByType(MethodCallExpressionModel model)
{ {
var parameter = model.Args[0].MemberName; throw new NotSupportedException("Oracle NotSupportedException DateIsSameDay");
var parameter2 = model.Args[1].MemberName;
var parameter3 = model.Args[2].MemberValue;
var type = (DateType)Enum.Parse(typeof(DateType), parameter3.ObjToString(), false);
int time = 1;
switch (type)
{
case DateType.Year:
time = time * 1 / 365;
break;
case DateType.Month:
time = time * 1 / 30;
break;
case DateType.Day:
break;
case DateType.Hour:
time = time * 24;
break;
case DateType.Second:
time = time * 24 * 60 * 60;
break;
case DateType.Minute:
time = time * 24 * 60;
break;
case DateType.Millisecond:
time = time * 24 * 60 * 60 * 1000;
break;
}
return string.Format(" (ROUND(TO_NUMBER({0} - {1}) * {2}) = 0) ", parameter, parameter2, time);
} }
public override string Length(MethodCallExpressionModel model) public override string Length(MethodCallExpressionModel model)
{ {

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

@ -345,7 +345,7 @@ namespace SqlSugar
public ISugarQueryable<T> SqlQueryable<T>(string sql) where T : class, new() public ISugarQueryable<T> SqlQueryable<T>(string sql) where T : class, new()
{ {
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig); var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
return this.Queryable<T>().AS(sqlBuilder.GetPackTable(sql, sqlBuilder.GetDefaultShortName())); return this.Queryable<T>().AS(sqlBuilder.GetPackTable(sql, sqlBuilder.GetDefaultShortName())).Select("*");
} }
#endregion #endregion

Loading…
Cancel
Save