From e937f51ae9e50c7a6cb3714525b925760e3171a6 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 23 Dec 2024 17:02:24 +0800 Subject: [PATCH] Add demo --- .../PgSqlTest/UserTestCases/Main.cs | 1 + .../PgSqlTest/UserTestCases/Unita1ddys.cs | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unita1ddys.cs diff --git a/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Main.cs b/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Main.cs index 6ba73c019..39882b0b7 100644 --- a/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Main.cs +++ b/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Main.cs @@ -32,6 +32,7 @@ namespace OrmTest } public static void Init() { + Unita1ddys.Init(); Unit1sdgsaaysdfa.Init(); UnitBulkMergeaa.Init(); Unitadsfayasdfaaay.Init(); diff --git a/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unita1ddys.cs b/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unita1ddys.cs new file mode 100644 index 000000000..af515c6a9 --- /dev/null +++ b/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unita1ddys.cs @@ -0,0 +1,54 @@ +using Microsoft.Identity.Client; +using Npgsql; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OrmTest +{ + internal class Unita1ddys + { + public static void Init() + { + var db = NewUnitTest.Db;//用于创建schema和删除schema + try + { + + db.Ado.ExecuteCommand("CREATE SCHEMA testcm"); + } + catch (Exception) + { + } + var newdb = NewUnitTest.Db.CopyNew();//新db指定schema实现crud + newdb.CurrentConnectionConfig.ConnectionString = Config.ConnectionString + ";searchpath=testcm"; + newdb.CodeFirst.InitTables(); + for (int i = 0; i < 3; i++) + { + Unitsdfafayas entity = new Unitsdfafayas() + { + Id = Guid.NewGuid().ToString(), + Annex = new List() { "12312321332" } + }; + newdb.Insertable(entity).ExecuteCommand(); + } + var communityEntities = newdb.Queryable().ToList(); + + var x = newdb.Storageable(communityEntities).ToStorage(); + x.AsInsertable.ExecuteCommand(); + x.AsUpdateable.ExecuteCommand(); + + System.Drawing.Point + } + public class Unitsdfafayas + { + [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] + public string Id { get; set; } + + [SugarColumn(ColumnName = "annex", ColumnDataType = "JSONB", IsJson = true)] + public List Annex { get; set; } + } + } +}