diff --git a/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Main.cs b/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Main.cs index 6a3431d6a..7a13fbabe 100644 --- a/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Main.cs +++ b/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + Unitadsfayasdfaaay.Init(); Unitafdafas.Init(); Unitadfaf2s.Init(); UnitWeek.Init(); diff --git a/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unitadfadfay.cs b/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unitadfadfay.cs new file mode 100644 index 000000000..78be82b89 --- /dev/null +++ b/Src/Asp.NetCore2/PgSqlTest/UserTestCases/Unitadfadfay.cs @@ -0,0 +1,83 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OrmTest +{ + public class Unitadsfayasdfaaay + { + [SugarTable("test_sqlsugar_table")] + public class TestSqlsugarTable + { + [SugarColumn(IsPrimaryKey = true)] public int id { get; set; } + [SugarColumn(IsArray = true, ColumnDataType = "int[]")] public int[] arr_col { get; set; } + [SugarColumn(IsJson = true, ColumnDataType = "jsonb")] public List json_col { get; set; } = new(); + public byte[] byte_col { get; set; } + public int int_col { get; set; } + } + + public static void Init() + { + TestInsert().GetAwaiter().GetResult(); + } + + public static async Task TestInsert() + { + var db = NewUnitTest.Db; + await InitDb(); + List list = new(); + for (int i = 0; i < 10; i++) + { + list.Add(new() + { + id = i + 1, + arr_col = new int[] { i + 11, i + 12, i + 13 }, + json_col = new List { i + 21, i + 22, i + 23 }, + byte_col = new byte[] { 100, 200, 3 }, + int_col = 1 + }); + } + + //string sql1 = db.Insertable(list[0]).ToSqlString(); + + //string sql = db.Insertable(list).ToSqlString(); + + //var rst1 = await db.Insertable(list).ExecuteCommandAsync(); + + var rst1 = await db.Fastest().BulkMergeAsync(list); + + Console.WriteLine(rst1); + + var list4 = await db.Queryable().ToListAsync(); + } + + + //public static async Task Read() + //{ + // var list = await db.Queryable().ToListAsync(); + //} + + public static async Task InitDb() + { + var db = NewUnitTest.Db; + await db.Ado.ExecuteCommandAsync("DROP TABLE IF EXISTS test_sqlsugar_table"); + if (!db.DbMaintenance.IsAnyTable("test_sqlsugar_table", false)) + { + db.CodeFirst.InitTables(typeof(TestSqlsugarTable)); + } + } + + } + [SugarTable("test_sqlsugar_table")] + public class TestSqlsugarTable + { + [SugarColumn(IsPrimaryKey = true)] public int id { get; set; } + [SugarColumn(IsArray = true, ColumnDataType = "int[]")] public int[] arr_col { get; set; } + [SugarColumn(IsJson = true, ColumnDataType = "jsonb")] public List json_col { get; set; } = new(); + public byte[] byte_col { get; set; } + public int int_col { get; set; } + } +}