mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Add demo
This commit is contained in:
parent
813ba6d299
commit
914781df6d
@ -18,6 +18,9 @@ namespace OrmTest
|
||||
ConnectionString = Config.ConnectionString3,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true
|
||||
},
|
||||
db => {
|
||||
db.Aop.OnLogExecuting = (s, p) => Console.WriteLine(s);
|
||||
});
|
||||
//db.DbMaintenance.CreateDatabase();
|
||||
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
|
||||
@ -25,6 +28,9 @@ namespace OrmTest
|
||||
var list = db.Queryable<CodeFirstTable1>().ToList();
|
||||
TestBool(db);
|
||||
TestGuid(db);
|
||||
db.CodeFirst.InitTables<CodeFirstTable2>();
|
||||
db.Insertable(new List<CodeFirstTable2>() { new CodeFirstTable2() { CreateTime = DateTime.Now, Name = "a", Text = new ulong[] { 1 } } }).ExecuteCommand();
|
||||
var list2=db.Queryable<CodeFirstTable2>().ToList();
|
||||
Console.WriteLine("#### CodeFirst end ####");
|
||||
}
|
||||
private static void TestGuid(SqlSugarClient db)
|
||||
@ -82,6 +88,16 @@ namespace OrmTest
|
||||
public long Id { get; set; }
|
||||
public bool A { get; set; }
|
||||
}
|
||||
public class CodeFirstTable2
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[SugarColumn(ColumnDataType = "Array(UInt64)",IsArray =true)]//custom
|
||||
public UInt64[] Text { get; set; }
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
public class CodeFirstTable1
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
|
Loading…
Reference in New Issue
Block a user