From deeed0b65b69672d4cace98ed5cfa449472021fd Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sun, 1 Oct 2023 19:45:43 +0800 Subject: [PATCH] Update TDengineTest --- Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs | 3 +-- .../Demo/ORMTest_Partial/1_CodeFirts.cs | 12 ++++++++++ .../Models/Unit/CodeFirstTest1.cs | 24 ++++++++++++++----- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs b/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs index 00a15651f..e8bc1874e 100644 --- a/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs +++ b/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest.cs @@ -29,8 +29,7 @@ namespace TDengineTest } } }); - - + //建表 CodeFirst(db); diff --git a/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest_Partial/1_CodeFirts.cs b/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest_Partial/1_CodeFirts.cs index 45488dc92..a8fb22c2d 100644 --- a/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest_Partial/1_CodeFirts.cs +++ b/Src/Asp.NetCore2/TDengineTest/Demo/ORMTest_Partial/1_CodeFirts.cs @@ -9,7 +9,19 @@ namespace TDengineTest { public static void CodeFirst(SqlSugarClient db) { + CodeFirst1(db); + db.CodeFirst.InitTables(); + db.Insertable(new AllCSharpTypes() { Ts = DateTime.Now, Boolean = true, Char = 'a', Decimal = Convert.ToDecimal(18.2), Int16 = 1, Int32 = 1, Int64 = 1, String = "2" }).ExecuteCommand(); + var list3 = db.Queryable().ToList(); + db.CodeFirst.InitTables(); + } + + private static void CodeFirst1(SqlSugarClient db) + { + db.CodeFirst.InitTables(); + db.Insertable(new CodeFirst1() { Boolean = true, Ts = DateTime.Now }).ExecuteCommand(); + var list = db.Queryable().ToList(); } } } diff --git a/Src/Asp.NetCore2/TDengineTest/Models/Unit/CodeFirstTest1.cs b/Src/Asp.NetCore2/TDengineTest/Models/Unit/CodeFirstTest1.cs index 8e799d46a..7e4f0e865 100644 --- a/Src/Asp.NetCore2/TDengineTest/Models/Unit/CodeFirstTest1.cs +++ b/Src/Asp.NetCore2/TDengineTest/Models/Unit/CodeFirstTest1.cs @@ -1,17 +1,21 @@ -using System; +using SqlSugar.TDengine; +using System; using System.Collections.Generic; using System.Text; namespace TDengineTest { - public class AllCSharpTypes + [SqlSugar.SugarTable("AllCSharpTypes09")] + public class AllCSharpTypes : STable { + [SqlSugar.SugarColumn(IsPrimaryKey = true)] + public DateTime Ts { get; set; } public bool Boolean { get; set; } public byte Byte { get; set; } public sbyte SByte { get; set; } public char Char { get; set; } public decimal Decimal { get; set; } - [SqlSugar.SugarColumn(Length =18,DecimalDigits =2)] + [SqlSugar.SugarColumn(Length = 18, DecimalDigits = 2)] public decimal Decimal2 { get; set; } [SqlSugar.SugarColumn(Length = 18, DecimalDigits = 2)] public double Double { get; set; } @@ -21,9 +25,17 @@ namespace TDengineTest public long Int64 { get; set; } public ulong UInt64 { get; set; } public short Int16 { get; set; } - public ushort UInt16 { get; set; } + public ushort UInt16 { get; set; } public string String { get; set; } - [SqlSugar.SugarColumn(Length =100)] + [SqlSugar.SugarColumn(Length = 100)] public string String2 { get; set; } } -} + + + public class CodeFirst1 : STable + { + [SqlSugar.SugarColumn(IsPrimaryKey = true)] + public DateTime Ts { get; set; } + public bool Boolean { get; set; } + } +} \ No newline at end of file