mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Add demo
This commit is contained in:
parent
813ba6d299
commit
914781df6d
@ -18,6 +18,9 @@ namespace OrmTest
|
|||||||
ConnectionString = Config.ConnectionString3,
|
ConnectionString = Config.ConnectionString3,
|
||||||
InitKeyType = InitKeyType.Attribute,
|
InitKeyType = InitKeyType.Attribute,
|
||||||
IsAutoCloseConnection = true
|
IsAutoCloseConnection = true
|
||||||
|
},
|
||||||
|
db => {
|
||||||
|
db.Aop.OnLogExecuting = (s, p) => Console.WriteLine(s);
|
||||||
});
|
});
|
||||||
//db.DbMaintenance.CreateDatabase();
|
//db.DbMaintenance.CreateDatabase();
|
||||||
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
|
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
|
||||||
@ -25,6 +28,9 @@ namespace OrmTest
|
|||||||
var list = db.Queryable<CodeFirstTable1>().ToList();
|
var list = db.Queryable<CodeFirstTable1>().ToList();
|
||||||
TestBool(db);
|
TestBool(db);
|
||||||
TestGuid(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 ####");
|
Console.WriteLine("#### CodeFirst end ####");
|
||||||
}
|
}
|
||||||
private static void TestGuid(SqlSugarClient db)
|
private static void TestGuid(SqlSugarClient db)
|
||||||
@ -82,6 +88,16 @@ namespace OrmTest
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public bool A { 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
|
public class CodeFirstTable1
|
||||||
{
|
{
|
||||||
[SugarColumn(IsPrimaryKey = true)]
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
Loading…
Reference in New Issue
Block a user