You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System;
namespace SqlSugar { public class SqliteInsertBuilder : InsertBuilder { public override string SqlTemplate { get { if (IsReturnIdentity) { return @"INSERT INTO {0}
({1}) VALUES ({2}) ;SELECT LAST_INSERT_ROWID();";
} else { return @"INSERT INTO {0}
({1}) VALUES ({2}) ;";
} } }
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 == UtilConstants.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.IsEnum()) { return Convert.ToInt64(value); } else if (type == UtilConstants.ByteArrayType) { var bytesString = "0x" + BitConverter.ToString((byte[])value); return bytesString; } else if (type == UtilConstants.BoolType) { return value.ObjToBool() ? "1" : "0"; } else if (type == UtilConstants.StringType || type == UtilConstants.ObjType) { return "'" + value.ToString().ToSqlFilter() + "'"; } else { return "'"+value.ToString() + "'"; } } } } }
|