Update Oracle

This commit is contained in:
sunkaixuan 2017-10-14 17:11:58 +08:00
parent d7cc1c190b
commit a82d174804
4 changed files with 75 additions and 3 deletions

View File

@ -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;";
}
}

View File

@ -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();
}

View File

@ -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() + "'";
}
}
}
}
}

View File

@ -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() + "'";
}
}
}
}
}