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();
db.Ado.BeginTran();
var t1 = db.Ado.SqlQuery<string>("select 'a'");
var t2 = db.Ado.GetInt("select 1");
var t3 = db.Ado.GetDataTable("select 1 as id");
var t1 = db.Ado.SqlQuery<string>("select 'a' from dual");
var t2 = db.Ado.GetInt("select 1 from dual");
var t3 = db.Ado.GetDataTable("select 1 as id from dual");
db.Ado.CommitTran();
//more
//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 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);
}
@ -359,7 +359,7 @@ namespace OrmTest.Demo
var db = GetInstance();
var join3 = db.Queryable("Student", "st")
.AddJoinInfo("School", "sh", "sh.id=st.schoolid")
.Where("st.id>@id")
.Where("st.id>:id")
.AddParameters(new { id = 1 })
.Select("st.*").ToList();
//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.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();
};
return db;

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

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

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

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

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

@ -60,7 +60,7 @@ namespace SqlSugar
}
public override IDataAdapter GetAdapter()
{
return new SqlDataAdapter();
return new OracleDataAdapter();
}
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)
{
var parameter = model.Args[0].MemberName;
var parameter2 = model.Args[1].MemberName;
return string.Format(" (ROUND(TO_NUMBER({0} - {1}))=0) ", parameter, parameter2);
throw new NotSupportedException("Oracle NotSupportedException DateIsSameDay");
}
public override string DateIsSameByType(MethodCallExpressionModel model)
{
var parameter = model.Args[0].MemberName;
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);
throw new NotSupportedException("Oracle NotSupportedException DateIsSameDay");
}
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()
{
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

Loading…
Cancel
Save