From 630b899d964f5e3d528cb77ea364134ba5d6a8ef Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 17 Dec 2022 12:24:11 +0800 Subject: [PATCH] Update Questdb --- Src/Asp.Net/QuestDbTest/Demo/UInsert3.cs | 65 +++++++++++++++++++ Src/Asp.Net/QuestDbTest/QuestDbTest.csproj | 1 + .../SqlBuilder/QuestDBInsertBuilder.cs | 6 +- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Src/Asp.Net/QuestDbTest/Demo/UInsert3.cs diff --git a/Src/Asp.Net/QuestDbTest/Demo/UInsert3.cs b/Src/Asp.Net/QuestDbTest/Demo/UInsert3.cs new file mode 100644 index 000000000..411a53867 --- /dev/null +++ b/Src/Asp.Net/QuestDbTest/Demo/UInsert3.cs @@ -0,0 +1,65 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data.SqlTypes; +using System.Linq; +using System.Security.Principal; +using System.Text; +using System.Threading.Tasks; + +namespace OrmTest +{ + internal class UInsert3 + { + public static void Init() + { + var db = new SqlSugarClient(new ConnectionConfig() + { + ConnectionString = "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;", + DbType = DbType.QuestDB, + LanguageType = LanguageType.Chinese, + IsAutoCloseConnection = true + }); + db.Aop.OnLogExecuted = (s, p) => Console.WriteLine(s); + db.CodeFirst.InitTables(); + db.Insertable(new Order1() { Name = "a" }).ExecuteReturnSnowflakeId(); + + db.Insertable(new List() { + new Order1() { Name = "a" }, + new Order1() { Name = "a" } + }).ExecuteCommand(); + + db.Insertable(new ORDER1() { Name = "a" }).ExecuteReturnSnowflakeId(); + } + + public class Order1 + { + [SugarColumn(IsPrimaryKey = true )] + public long Id { get; set; } + /// + /// 姓名 + /// + public string Name { get; set; } + public decimal Price { get; set; } + [SugarColumn(InsertServerTime =true)] + public DateTime CreateTime { get; set; } + [SugarColumn(IsNullable = true)] + public int CustomId { get; set; } + } + [SugarTable("Order1")] + public class ORDER1 + { + [SugarColumn(IsPrimaryKey = true )] + public long Id { get; set; } + /// + /// 姓名 + /// + public string Name { get; set; } + public decimal Price { get; set; } + [SugarColumn(InsertSql = "now()")] + public DateTime CreateTime { get; set; } + [SugarColumn(IsNullable = true)] + public int CustomId { get; set; } + } + } +} diff --git a/Src/Asp.Net/QuestDbTest/QuestDbTest.csproj b/Src/Asp.Net/QuestDbTest/QuestDbTest.csproj index ac8c8fc66..bcdabf515 100644 --- a/Src/Asp.Net/QuestDbTest/QuestDbTest.csproj +++ b/Src/Asp.Net/QuestDbTest/QuestDbTest.csproj @@ -64,6 +64,7 @@ + diff --git a/Src/Asp.Net/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBInsertBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBInsertBuilder.cs index abc6bdd15..75eff4827 100644 --- a/Src/Asp.Net/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBInsertBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBInsertBuilder.cs @@ -50,7 +50,7 @@ namespace SqlSugar //{ // return $"to_timestamp('{it.Value.ObjToString("yyyy-MM-ddTHH:mm:ss")}', 'yyyy-MM-ddTHH:mm:ss')"; //} - return spk; + return GetDbColumn(it,spk); } )); @@ -77,6 +77,10 @@ namespace SqlSugar } batchInsetrSql.Append("\r\n ( " + string.Join(",", columns.Select(it => { + if (it.InsertServerTime || it.InsertSql.HasValue()) + { + return GetDbColumn(it,null); + } object value = null; if (it.Value is DateTime) {