From 3518862257c3a7ca7742f45c0dbe8484b267341a Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Thu, 27 Jun 2024 11:20:20 +0800
Subject: [PATCH] =?UTF-8?q?=E8=99=9A=E8=B0=B7=E6=95=B0=E6=8D=AE=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DataTableExtensions/XuguDataAdapter.cs | 98 +++++
.../SqlSugar.XuguCore.csproj | 26 ++
.../SqlSugar.XuguCore/Tools/ErrorMessage.cs | 64 +++
.../SqlSugar.XuguCore/Tools/FileHelper.cs | 57 +++
.../SqlSugar.XuguCore/Tools/UtilConstants.cs | 73 ++++
.../SqlSugar.XuguCore/Tools/UtilExtensions.cs | 100 +++++
.../SqlSugar.XuguCore/Tools/UtilMethods.cs | 398 ++++++++++++++++++
.../Tools/ValidateExtensions.cs | 147 +++++++
.../Xugu/CodeFirst/XuguCodeFirst.cs | 97 +++++
.../Xugu/DbBind/XuguDbBind.cs | 102 +++++
.../Xugu/DbFirst/XuguDbFirst.cs | 9 +
.../Xugu/DbMaintenance/XuguDbMaintenance.cs | 334 +++++++++++++++
.../Xugu/Queryable/XuguQueryable.cs | 58 +++
.../Xugu/SqlBuilder/XuguBlukCopy.cs | 129 ++++++
.../Xugu/SqlBuilder/XuguBuilder.cs | 29 ++
.../Xugu/SqlBuilder/XuguDeleteBuilder.cs | 10 +
.../Xugu/SqlBuilder/XuguExpressionContext.cs | 97 +++++
.../Xugu/SqlBuilder/XuguFastBuilder.cs | 44 ++
.../Xugu/SqlBuilder/XuguInsertBuilder.cs | 115 +++++
.../Xugu/SqlBuilder/XuguQueryBuilder.cs | 112 +++++
.../Xugu/SqlBuilder/XuguUpdateBuilder.cs | 78 ++++
.../SqlSugar.XuguCore/Xugu/XuguEntry.cs | 34 ++
.../SqlSugar.XuguCore/Xugu/XuguProvider.cs | 283 +++++++++++++
Src/Asp.NetCore2/SqlSugarCore.sln | 31 +-
Src/Asp.NetCore2/XuGuTest/2XuGuTest.csproj | 19 +
Src/Asp.NetCore2/XuGuTest/BaseDataLogic.cs | 216 ++++++++++
Src/Asp.NetCore2/XuGuTest/Program.cs | 56 +++
Src/Asp.NetCore2/XuGuTest/T_USER.cs | 329 +++++++++++++++
28 files changed, 3144 insertions(+), 1 deletion(-)
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/DataTableExtensions/XuguDataAdapter.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/SqlSugar.XuguCore.csproj
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/ErrorMessage.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/FileHelper.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/UtilConstants.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/UtilExtensions.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/UtilMethods.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/ValidateExtensions.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/CodeFirst/XuguCodeFirst.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/DbBind/XuguDbBind.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/DbFirst/XuguDbFirst.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/DbMaintenance/XuguDbMaintenance.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/Queryable/XuguQueryable.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/SqlBuilder/XuguBlukCopy.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/SqlBuilder/XuguBuilder.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/SqlBuilder/XuguDeleteBuilder.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/SqlBuilder/XuguExpressionContext.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/SqlBuilder/XuguFastBuilder.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/SqlBuilder/XuguInsertBuilder.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/SqlBuilder/XuguQueryBuilder.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/SqlBuilder/XuguUpdateBuilder.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/XuguEntry.cs
create mode 100644 Src/Asp.NetCore2/SqlSugar.XuguCore/Xugu/XuguProvider.cs
create mode 100644 Src/Asp.NetCore2/XuGuTest/2XuGuTest.csproj
create mode 100644 Src/Asp.NetCore2/XuGuTest/BaseDataLogic.cs
create mode 100644 Src/Asp.NetCore2/XuGuTest/Program.cs
create mode 100644 Src/Asp.NetCore2/XuGuTest/T_USER.cs
diff --git a/Src/Asp.NetCore2/SqlSugar.XuguCore/DataTableExtensions/XuguDataAdapter.cs b/Src/Asp.NetCore2/SqlSugar.XuguCore/DataTableExtensions/XuguDataAdapter.cs
new file mode 100644
index 000000000..49cf97363
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.XuguCore/DataTableExtensions/XuguDataAdapter.cs
@@ -0,0 +1,98 @@
+using System.Data;
+using XuguClient;
+
+namespace SqlSugar.Xugu
+{
+ ///
+ /// 虚谷数据填充器
+ ///
+ public class XuguDataAdapter : IDataAdapter
+ {
+ private string sql;
+ private XGConnection _sqlConnection;
+ private XGCommand command;
+ ///
+ /// 构造函数
+ ///
+ public XuguDataAdapter() { }
+ ///
+ /// 构造函数
+ ///
+ /// SQL命令
+ public XuguDataAdapter(XGCommand command) => this.command = command;
+ ///
+ /// 构造函数
+ ///
+ /// SQL语句
+ /// 连接对象
+ public XuguDataAdapter(string sql, XGConnection _sqlConnection)
+ {
+ this.sql = sql;
+ this._sqlConnection = _sqlConnection;
+ }
+ ///
+ /// 查询SQL命令对象
+ ///
+ public XGCommand SelectCommand
+ {
+ get
+ {
+ if (this.command == null)
+ {
+ this.command = this._sqlConnection.CreateCommand();
+ this.command.CommandText = sql;
+ }
+ return this.command;
+ }
+ set
+ {
+ this.command = value;
+ }
+ }
+ ///
+ /// 填充数据(当前集合)
+ ///
+ /// 填充目标DataTable
+ private DataTable Fill(XGDataReader dr, DataTable dt = null)
+ {
+ if (dt == null) dt = new DataTable();
+ var columns = dt.Columns;
+ //构造列
+ for (int i = 0; i < dr.FieldCount; i++)
+ {
+ string name = dr.GetName(i).Trim();
+ //重名时的处理
+ if (!columns.Contains(name)) name += i;
+ columns.Add(new DataColumn(name, dr.GetFieldType(i)));
+ }
+ //填充行
+ while (dr.Read())
+ {
+ DataRow row = dt.NewRow();
+ for (int i = 0; i < columns.Count; i++)
+ row[columns[i].ColumnName] = dr.GetValue(i);
+ dt.Rows.Add(row);
+ }
+ dt.AcceptChanges();
+ return dt;
+ }
+ ///
+ /// 填充数据(单个集合)
+ ///
+ /// 填充目标DataTable
+ public void Fill(DataTable dt) { using (var dr = command.ExecuteReader()) Fill(dt); }
+ ///
+ /// 填充数据(多个集合)
+ ///
+ /// 填充目标DataSet
+ public void Fill(DataSet ds)
+ {
+ if (ds == null) ds = new DataSet();
+ using (var dr = command.ExecuteReader())
+ {
+ do ds.Tables.Add(Fill(dr));
+ while (dr.NextResult());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Asp.NetCore2/SqlSugar.XuguCore/SqlSugar.XuguCore.csproj b/Src/Asp.NetCore2/SqlSugar.XuguCore/SqlSugar.XuguCore.csproj
new file mode 100644
index 000000000..1e96aa945
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.XuguCore/SqlSugar.XuguCore.csproj
@@ -0,0 +1,26 @@
+
+
+
+ netstandard2.1
+ enable
+ True
+ SqlSugar操作 Xugu 虚谷数据库
+ SqlSugar操作 Xugu 虚谷数据库
+ dreamsfly900
+ 1.0.3
+ 北京知天智为气象科技有限公司
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/ErrorMessage.cs b/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/ErrorMessage.cs
new file mode 100644
index 000000000..40f82f3e1
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/ErrorMessage.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+namespace SqlSugar.Xugu
+{
+ internal static partial class ErrorMessage
+ {
+ internal static LanguageType SugarLanguageType { get; set; } = LanguageType.Default;
+ internal static string ObjNotExist
+ {
+ get
+ {
+ return GetThrowMessage("{0} does not exist.",
+ "{0}不存在。");
+ }
+ }
+ internal static string EntityMappingError
+ {
+ get
+ {
+ return GetThrowMessage("Entity mapping error.{0}",
+ "实体与表映射出错。{0}");
+ }
+ }
+
+ public static string NotSupportedDictionary
+ {
+ get
+ {
+ return GetThrowMessage("This type of Dictionary is not supported for the time being. You can try Dictionary, or contact the author!!",
+ "暂时不支持该类型的Dictionary 你可以试试 Dictionary或者联系作者!!");
+ }
+ }
+
+ public static string NotSupportedArray
+ {
+ get
+ {
+ return GetThrowMessage("This type of Array is not supported for the time being. You can try object[] or contact the author!!",
+ "暂时不支持该类型的Array 你可以试试 object[] 或者联系作者!!");
+ }
+ }
+
+ internal static string GetThrowMessage(string enMessage, string cnMessage, params string[] args)
+ {
+ if (SugarLanguageType == LanguageType.Default)
+ {
+ List formatArgs = new List() { enMessage, cnMessage };
+ formatArgs.AddRange(args);
+ return string.Format(@"中文提示 : {1}
+English Message : {0}", formatArgs.ToArray());
+ }
+ else if (SugarLanguageType == LanguageType.English)
+ {
+ return enMessage;
+ }
+ else
+ {
+ return cnMessage;
+ }
+ }
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/FileHelper.cs b/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/FileHelper.cs
new file mode 100644
index 000000000..254d5c583
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/FileHelper.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace SqlSugar.Xugu
+{
+ internal class FileHelper
+ {
+ public static void CreateFile(string filePath, string text, Encoding encoding)
+ {
+ try
+ {
+ if (IsExistFile(filePath)) DeleteFile(filePath);
+ if (!IsExistFile(filePath))
+ {
+ string directoryPath = GetDirectoryFromFilePath(filePath);
+ CreateDirectory(directoryPath);
+
+ FileInfo file = new FileInfo(filePath);
+ using (FileStream stream = file.Create())
+ {
+ using (StreamWriter writer = new StreamWriter(stream, encoding))
+ {
+ writer.Write(text);
+ writer.Flush();
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+ public static bool IsExistDirectory(string directoryPath)
+ {
+ return Directory.Exists(directoryPath);
+ }
+ public static void CreateDirectory(string directoryPath)
+ {
+ if (!IsExistDirectory(directoryPath)) Directory.CreateDirectory(directoryPath);
+ }
+ public static void DeleteFile(string filePath)
+ {
+ if (IsExistFile(filePath)) File.Delete(filePath);
+ }
+ public static string GetDirectoryFromFilePath(string filePath)
+ {
+ FileInfo file = new FileInfo(filePath);
+ DirectoryInfo directory = file.Directory;
+ return directory.FullName;
+ }
+ public static bool IsExistFile(string filePath)=> File.Exists(filePath);
+ }
+}
diff --git a/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/UtilConstants.cs b/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/UtilConstants.cs
new file mode 100644
index 000000000..d0adefdf0
--- /dev/null
+++ b/Src/Asp.NetCore2/SqlSugar.XuguCore/Tools/UtilConstants.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Text;
+namespace SqlSugar.Xugu
+{
+ internal static class UtilConstants
+ {
+ public const string Dot = ".";
+ public const char DotChar = '.';
+ internal const string Space = " ";
+ internal const char SpaceChar =' ';
+ internal const string AssemblyName = "SqlSugar";
+ internal const string ReplaceKey = "{662E689B-17A1-4D06-9D27-F29EAB8BC3D6}";
+ internal const string ReplaceCommaKey = "{112A689B-17A1-4A06-9D27-A39EAB8BC3D5}";
+
+ internal static Type IntType = typeof(int);
+ internal static Type LongType = typeof(long);
+ internal static Type GuidType = typeof(Guid);
+ internal static Type BoolType = typeof(bool);
+ internal static Type BoolTypeNull = typeof(bool?);
+ internal static Type ByteType = typeof(Byte);
+ internal static Type ObjType = typeof(object);
+ internal static Type DobType = typeof(double);
+ internal static Type FloatType = typeof(float);
+ internal static Type ShortType = typeof(short);
+ internal static Type DecType = typeof(decimal);
+ internal static Type StringType = typeof(string);
+ internal static Type DateType = typeof(DateTime);
+ internal static Type DateTimeOffsetType = typeof(DateTimeOffset);
+ internal static Type TimeSpanType = typeof(TimeSpan);
+ internal static Type ByteArrayType = typeof(byte[]);
+ internal static Type ModelType= typeof(ModelContext);
+ internal static Type DynamicType = typeof(ExpandoObject);
+ internal static Type Dicii = typeof(KeyValuePair);
+ internal static Type DicIS = typeof(KeyValuePair);
+ internal static Type DicSi = typeof(KeyValuePair);
+ internal static Type DicSS = typeof(KeyValuePair);
+ internal static Type DicOO = typeof(KeyValuePair