From e140955e196d10d6357474cfff1771a5ec6c1881 Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Tue, 7 Nov 2023 19:50:03 +0800
Subject: [PATCH] Add Vastbase test
---
Src/Asp.NetCore2/SqlSugarCore.sln | 14 ++++
.../VastbaseTest/2VastbaseTest.csproj | 12 ++++
Src/Asp.NetCore2/VastbaseTest/Program.cs | 68 +++++++++++++++++++
3 files changed, 94 insertions(+)
create mode 100644 Src/Asp.NetCore2/VastbaseTest/2VastbaseTest.csproj
create mode 100644 Src/Asp.NetCore2/VastbaseTest/Program.cs
diff --git a/Src/Asp.NetCore2/SqlSugarCore.sln b/Src/Asp.NetCore2/SqlSugarCore.sln
index 078e613a5..b68e20c2c 100644
--- a/Src/Asp.NetCore2/SqlSugarCore.sln
+++ b/Src/Asp.NetCore2/SqlSugarCore.sln
@@ -68,6 +68,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlSugar.TDengineCore", "Sq
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "1TDengineTest", "TDengineTest\1TDengineTest.csproj", "{AFBF6813-DA87-4621-9659-5D123234CDDF}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2VastbaseTest", "VastbaseTest\2VastbaseTest.csproj", "{FA0F2233-7BD5-49A0-8333-BA471509F2D7}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -426,6 +428,18 @@ Global
{AFBF6813-DA87-4621-9659-5D123234CDDF}.Release|ARM32.Build.0 = Release|Any CPU
{AFBF6813-DA87-4621-9659-5D123234CDDF}.Release|x86.ActiveCfg = Release|Any CPU
{AFBF6813-DA87-4621-9659-5D123234CDDF}.Release|x86.Build.0 = Release|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Debug|ARM32.ActiveCfg = Debug|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Debug|ARM32.Build.0 = Debug|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Debug|x86.Build.0 = Debug|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Release|ARM32.ActiveCfg = Release|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Release|ARM32.Build.0 = Release|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Release|x86.ActiveCfg = Release|Any CPU
+ {FA0F2233-7BD5-49A0-8333-BA471509F2D7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Src/Asp.NetCore2/VastbaseTest/2VastbaseTest.csproj b/Src/Asp.NetCore2/VastbaseTest/2VastbaseTest.csproj
new file mode 100644
index 000000000..25fd441e7
--- /dev/null
+++ b/Src/Asp.NetCore2/VastbaseTest/2VastbaseTest.csproj
@@ -0,0 +1,12 @@
+
+
+
+ Exe
+ net5.0
+
+
+
+
+
+
+
diff --git a/Src/Asp.NetCore2/VastbaseTest/Program.cs b/Src/Asp.NetCore2/VastbaseTest/Program.cs
new file mode 100644
index 000000000..094dd14c1
--- /dev/null
+++ b/Src/Asp.NetCore2/VastbaseTest/Program.cs
@@ -0,0 +1,68 @@
+using SqlSugar;
+using System;
+
+namespace OrmTest
+{
+
+ public class Program
+ {
+ static void Main(string[] args)
+ {
+ var db = DbHelper.GetNewDb();
+
+ db.CodeFirst.InitTables();
+ db.Insertable(new DataType1() { Id = 1,id2=Convert.ToDecimal(1.2),id3="aa" }).ExecuteCommand();
+ var list=db.Queryable().ToList();
+
+ }
+ }
+
+ public class DataType1
+ {
+ [SugarColumn(ColumnDataType ="integer")]
+ public int Id { get; set; }
+ [SugarColumn(ColumnDataType ="money",IsNullable =true)]
+ public decimal id2 { get; set; }
+ [SugarColumn(ColumnDataType = "varchar2", IsNullable = true)]
+ public string id3 { get; set; }
+ }
+
+ ///
+ /// Helper class for database operations
+ /// 数据库操作的辅助类
+ ///
+ public class DbHelper
+ {
+ ///
+ /// Database connection string
+ /// 数据库连接字符串
+ ///
+ public readonly static string Connection = "PORT=5410;DATABASE=sqlsugar_test;HOST=116.63.182.54;PASSWORD=Test@123456abc;USER ID=test;No Reset On Close=true";
+
+ ///
+ /// Get a new SqlSugarClient instance with specific configurations
+ /// 获取具有特定配置的新 SqlSugarClient 实例
+ ///
+ /// SqlSugarClient instance
+ public static SqlSugarClient GetNewDb()
+ {
+ var db = new SqlSugarClient(new ConnectionConfig()
+ {
+ IsAutoCloseConnection = true,
+ DbType = DbType.Vastbase,
+ ConnectionString = Connection,
+ LanguageType=LanguageType.Default//Set language
+
+ },
+ it => {
+ // Logging SQL statements and parameters before execution
+ // 在执行前记录 SQL 语句和参数
+ it.Aop.OnLogExecuting = (sql, para) =>
+ {
+ Console.WriteLine(UtilMethods.GetNativeSql(sql, para));
+ };
+ });
+ return db;
+ }
+ }
+}
\ No newline at end of file