mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Add GBase demo
This commit is contained in:
parent
9b0d3bed1c
commit
6f4e4f1894
@ -23,10 +23,26 @@ namespace OrmTest
|
||||
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
|
||||
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
|
||||
var list = db.Queryable<CodeFirstTable1>().ToList();
|
||||
db.CodeFirst.InitTables<CodeFirstTable2>();
|
||||
db.DbMaintenance.TruncateTable<CodeFirstTable2>();
|
||||
db.Insertable(new CodeFirstTable2() { IsOk = true, Name = "a", Text = "a" }).ExecuteCommand();
|
||||
db.Insertable(new CodeFirstTable2() { IsOk = false, Name = "a", Text = "a" }).ExecuteCommand();
|
||||
var data= db.Queryable<CodeFirstTable2>().Where(it => it.IsOk==true).First();
|
||||
var data2 = db.Queryable<CodeFirstTable2>().Where(it => it.IsOk == false).First();
|
||||
db.Updateable(data).ExecuteCommand();
|
||||
Console.WriteLine("#### CodeFirst end ####");
|
||||
}
|
||||
}
|
||||
|
||||
public class CodeFirstTable2
|
||||
{
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[SugarColumn(ColumnDataType = "varchar(255)")]//custom
|
||||
public string Text { get; set; }
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public bool IsOk { get; set; }
|
||||
}
|
||||
public class CodeFirstTable1
|
||||
{
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
|
Loading…
Reference in New Issue
Block a user