mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update Oracle
This commit is contained in:
parent
d7cc1c190b
commit
a82d174804
@ -8,6 +8,6 @@ namespace OrmTest
|
||||
{
|
||||
public class Config
|
||||
{
|
||||
public static string ConnectionString = "Data Source=localhost/orcl;User ID=system;Password=JHL52771jhl;";
|
||||
public static string ConnectionString = "Data Source=kobato.meibu.net/orclpdb;User ID=sa;Password=123456;";
|
||||
}
|
||||
}
|
||||
|
@ -48,9 +48,9 @@ namespace OrmTest.Demo
|
||||
var insertObjs = new List<Student>();
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
insertObjs.Add(new Student() { Name = "name" + i });
|
||||
insertObjs.Add(new Student() { Name = "name" + i ,CreateTime=DateTime.Now});
|
||||
}
|
||||
var t10 = db.Insertable(insertObjs.ToArray()).InsertColumns(it => new { it.Name }).ExecuteCommand();
|
||||
var t10 = db.Insertable(insertObjs.ToArray()).InsertColumns(it => new { it.Name,it.CreateTime }).ExecuteCommand();
|
||||
|
||||
var t11 = db.Insertable(insertObjs.ToArray()).ExecuteCommand();
|
||||
}
|
||||
|
@ -87,5 +87,41 @@ namespace SqlSugar
|
||||
return "BEGIN\r\n"+ batchInsetrSql.ToString()+"\r\nEND;";
|
||||
}
|
||||
}
|
||||
public override object FormatValue(object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
var type = value.GetType();
|
||||
if (type == UtilConstants.DateType)
|
||||
{
|
||||
var date = value.ObjToDate();
|
||||
if (date < Convert.ToDateTime("1900-1-1"))
|
||||
{
|
||||
date = Convert.ToDateTime("1900-1-1");
|
||||
}
|
||||
return "to_date('"+ date.ToString("yyyy-MM-dd HH:mm:ss") + "', 'YYYY-MM-DD HH24:MI:SS') ";
|
||||
}
|
||||
else if (type.IsEnum())
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
else if (type == UtilConstants.BoolType)
|
||||
{
|
||||
return value.ObjToBool() ? "1" : "0";
|
||||
}
|
||||
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
||||
{
|
||||
return "N'" + value.ToString().ToSqlFilter() + "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "N'" + value.ToString() + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,41 @@ namespace SqlSugar
|
||||
{
|
||||
public class OracleUpdateBuilder : UpdateBuilder
|
||||
{
|
||||
public override object FormatValue(object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return "NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
var type = value.GetType();
|
||||
if (type == UtilConstants.DateType)
|
||||
{
|
||||
var date = value.ObjToDate();
|
||||
if (date < Convert.ToDateTime("1900-1-1"))
|
||||
{
|
||||
date = Convert.ToDateTime("1900-1-1");
|
||||
}
|
||||
return "to_date('" + date.ToString("yyyy-MM-dd HH:mm:ss") + "', 'YYYY-MM-DD HH24:MI:SS') ";
|
||||
}
|
||||
else if (type.IsEnum())
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
else if (type == UtilConstants.BoolType)
|
||||
{
|
||||
return value.ObjToBool() ? "1" : "0";
|
||||
}
|
||||
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
||||
{
|
||||
return "N'" + value.ToString().ToSqlFilter() + "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "N'" + value.ToString() + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user