Upadte Sqlite

This commit is contained in:
sunkaixuan 2017-07-10 01:01:31 +08:00
parent b68e26b17a
commit 2a900481fd
2 changed files with 44 additions and 1 deletions

View File

@ -1,4 +1,6 @@
namespace SqlSugar
using System;
namespace SqlSugar
{
public class SqliteInsertBuilder : InsertBuilder
{
@ -23,5 +25,46 @@
}
}
}
public override string SqlTemplateBatch
{
get
{
return "INSERT INTO {0} ({1})";
}
}
public override object FormatValue(object value)
{
if (value == null)
{
return "NULL";
}
else
{
var type = value.GetType();
if (type == PubConst.DateType)
{
var date = value.ObjToDate();
if (date < Convert.ToDateTime("1900-1-1"))
{
date = Convert.ToDateTime("1900-1-1");
}
return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'";
}
else if (type == PubConst.BoolType)
{
return value.ObjToBool() ? "1" : "0";
}
else if (type == PubConst.StringType || type == PubConst.ObjType)
{
return "'" + value.ToString().ToSqlFilter() + "'";
}
else
{
return "'"+value.ToString() + "'";
}
}
}
}
}