namespace IStation.DAL
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public class ScheduleAnaLog
|
{
|
public SqlSugarClient Connection
|
{
|
get { return ConfigHelper.GetSqlSugarClient(); }
|
}
|
|
|
// private readonly string _createTable = "(\r\n\r\n `ID` Int32,\r\n\r\n `Info` Nullable(String),\r\n\r\n `CreateTime` Nullable(DateTime)\r\n)\r\nENGINE = MergeTree\r\nPRIMARY KEY ID\r\nORDER BY ID\r\nSETTINGS index_granularity = 8192;";
|
private readonly string _createTable = "(\r\n\r\n `Info` String ,\r\n\r\n `CreateTime` DateTime \r\n)\r\nENGINE = Log \r\n ";
|
|
|
public void CreatTable()
|
{
|
using (SqlSugarClient db = Connection)
|
{
|
var sql_exist_table = "SELECT COUNT(*) FROM system.tables WHERE database = 'default' AND name = 'ScheduleAnaLog'";
|
if (db.Ado.GetInt(sql_exist_table) < 1)
|
{
|
var sql_create_table = $"CREATE TABLE default.ScheduleAnaLog {_createTable}";
|
db.Ado.ExecuteCommand(sql_create_table);
|
}
|
|
}
|
}
|
|
/// <summary>
|
/// 插入指定对象到数据库中
|
/// </summary>
|
public int Insert(Entity.ScheduleAnaLog entity)
|
{
|
if (entity == null)
|
return default;
|
using (SqlSugarClient db = Connection)
|
{
|
var sql_inset = $"INSERT INTO \"ScheduleAnaLog\" (\"Info\",\"CreateTime\") VALUES ('{entity.Info}','{entity.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")}') ;"; // SELECT 1 ";
|
return db.Ado.ExecuteCommand(sql_inset);
|
}
|
}
|
|
|
}
|
}
|