From 8db9a9b78bd305a82e4f78daecddbc170ff9c6dd Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 2 Jan 2023 13:21:35 +0800 Subject: [PATCH] Add demo --- Src/Asp.Net/PgSqlTest/Demo/DemoE_CodeFirst.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Src/Asp.Net/PgSqlTest/Demo/DemoE_CodeFirst.cs b/Src/Asp.Net/PgSqlTest/Demo/DemoE_CodeFirst.cs index 36476de5b..937a537cd 100644 --- a/Src/Asp.Net/PgSqlTest/Demo/DemoE_CodeFirst.cs +++ b/Src/Asp.Net/PgSqlTest/Demo/DemoE_CodeFirst.cs @@ -50,9 +50,34 @@ namespace OrmTest .SetColumns(it => it.longs == new long[] { 1, 2 }) .Where(it=>it.id==1) .ExecuteCommand(); + db.Aop.OnLogExecuting = (s, p) => Console.WriteLine(s); + db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings() + { + PgSqlIsAutoToLowerCodeFirst = false, + PgSqlIsAutoToLower=false + }; + db.CodeFirst.InitTables(); + db.Insertable(new CodeFirstNoUpper() { Id = Guid.NewGuid() + "", Name = "a" }).ExecuteCommand(); + var list6= db.Queryable().Where(it => it.Id != null).ToList(); + db.Updateable(list6).ExecuteCommand(); + db.Deleteable(list6).ExecuteCommand(); + db.Updateable(list6.First()).ExecuteCommand(); + db.Deleteable().Where(it => it.Id != null).ExecuteCommand(); + db.Updateable().SetColumns(it => it.Name == "a").Where(it => it.Id != null).ExecuteCommand(); + db.Updateable().SetColumns(it => new CodeFirstNoUpper() + { + Name = "a" + }).Where(it => it.Id != null).ExecuteCommand(); Console.WriteLine("#### CodeFirst end ####"); } } + [SugarTable(null,"备注表")] + public class CodeFirstNoUpper + { + [SugarColumn(IsPrimaryKey = true, ColumnDescription ="备注列")] + public string Id { get; set; } + public string Name { get; set; } + } public class CodeFirstArraryBigInt { [SugarColumn(IsPrimaryKey =true)]