update demo

This commit is contained in:
sunkaixuan 2023-04-21 21:17:11 +08:00
parent 3ea4977b8c
commit a891cf00fc

View File

@ -20,7 +20,8 @@ namespace OrmTest
InitKeyType = InitKeyType.Attribute, InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true IsAutoCloseConnection = true
}); });
db.DbMaintenance.CreateDatabase(); db.DbMaintenance.CreateDatabase();
db.Aop.OnLogExecuting = (s, p) =>Console.WriteLine( UtilMethods.GetNativeSql(s, p));
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1 db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand(); db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
var list = db.Queryable<CodeFirstTable1>().ToList(); var list = db.Queryable<CodeFirstTable1>().ToList();
@ -138,7 +139,7 @@ namespace OrmTest
public string Name { get; set; } public string Name { get; set; }
[SugarColumn(ColumnDataType = "varchar(255)")]//custom [SugarColumn(ColumnDataType = "varchar(255)")]//custom
public string Text { get; set; } public string Text { get; set; }
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true,DefaultValue = "current_timestamp")]
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
} }
} }