SqlSugar源码
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.

41 lines
1.1 KiB

3 years ago
using System;
using System.Collections.Generic;
3 years ago
using System.Linq;
3 years ago
using System.Text;
using SqlSugar;
namespace OrmTest
{
public class UCustom02
{
public static void Init()
{
var db = NewUnitTest.Db;
//建表
if (!db.DbMaintenance.IsAnyTable("Test001", false))
{
db.CodeFirst.InitTables<UnitTest001>();
}
var dt = DateTime.Now;
db.Aop.OnLogExecuting = (sql, pars) =>
{
3 years ago
3 years ago
};
//用例代码
var result = db.Insertable(new UnitTest001() { id = dt }).ExecuteCommand();//用例代码
3 years ago
var lastId = db.Queryable<UnitTest001>().ToList().Last().id;
var res = db.Queryable<UnitTest001>().WhereClass(new UnitTest001() { id = lastId }).ToList();
3 years ago
if (res.Count == 0)
{
throw new Exception("unit error");
}
}
public class UnitTest001
{
[SugarColumn(ColumnDataType = "TIMESTAMP")]
public DateTime id { get; set; }
}
}
}