林豪 左 1 year ago
parent
commit
2c820e7653
30 changed files with 3470 additions and 0 deletions
  1. BIN
      SqlSugar.BzTDengineCore/NuGet.exe
  2. 12 0
      SqlSugar.BzTDengineCore/STable.cs
  3. 13 0
      SqlSugar.BzTDengineCore/SqlSugar - Backup.TDengineCore.csproj
  4. 13 0
      SqlSugar.BzTDengineCore/SqlSugar.BzTDengineCore.csproj
  5. 24 0
      SqlSugar.BzTDengineCore/SqlSugar.OdbcCore.nuspec
  6. 206 0
      SqlSugar.BzTDengineCore/TDengine/CodeFirst/TDengineCodeFirst.cs
  7. 109 0
      SqlSugar.BzTDengineCore/TDengine/DbBind/TDengineDbBind.cs
  8. 6 0
      SqlSugar.BzTDengineCore/TDengine/DbFirst/TDengineDbFirst.cs
  9. 558 0
      SqlSugar.BzTDengineCore/TDengine/DbMaintenance/TDengineDbMaintenance.cs
  10. 99 0
      SqlSugar.BzTDengineCore/TDengine/Insertable/TDengineInserttable.cs
  11. 64 0
      SqlSugar.BzTDengineCore/TDengine/Queryable/TDengineSqlQueryable.cs
  12. 143 0
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineBuilder.cs
  13. 6 0
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineDeleteBuilder.cs
  14. 459 0
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineExpressionContext.cs
  15. 50 0
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineFastBuilder.cs
  16. 186 0
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineInsertBuilder.cs
  17. 129 0
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineQueryBuilder.cs
  18. 19 0
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineUpdateBuilder.cs
  19. 127 0
      SqlSugar.BzTDengineCore/TDengine/TDengineProvider.cs
  20. 155 0
      SqlSugar.BzTDengineCore/TDengineDataAdapter.cs
  21. 21 0
      SqlSugar.BzTDengineCore/Tools/DateTime16.cs
  22. 26 0
      SqlSugar.BzTDengineCore/Tools/DateTime19.cs
  23. 64 0
      SqlSugar.BzTDengineCore/Tools/ErrorMessage.cs
  24. 73 0
      SqlSugar.BzTDengineCore/Tools/FileHelper.cs
  25. 70 0
      SqlSugar.BzTDengineCore/Tools/UtilConstants.cs
  26. 136 0
      SqlSugar.BzTDengineCore/Tools/UtilExtensions.cs
  27. 521 0
      SqlSugar.BzTDengineCore/Tools/UtilMethods.cs
  28. 173 0
      SqlSugar.BzTDengineCore/Tools/ValidateExtensions.cs
  29. 1 0
      SqlSugar.BzTDengineCore/nuget.bat
  30. 7 0
      WcsFramework.sln

BIN
SqlSugar.BzTDengineCore/NuGet.exe


+ 12 - 0
SqlSugar.BzTDengineCore/STable.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SqlSugar.TDengine
+{
+    public class STable
+    {
+        [SugarColumn(IsOnlyIgnoreInsert =true ,IsOnlyIgnoreUpdate =true)]
+        public string TagsTypeId { get; set; } 
+    }
+}

+ 13 - 0
SqlSugar.BzTDengineCore/SqlSugar - Backup.TDengineCore.csproj

@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.1</TargetFramework>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="SqlSugarCore" Version="5.1.4.93" />
+    <PackageReference Include="TDengine.Ado.Data" Version="1.4.0" />
+  </ItemGroup>
+
+</Project>

+ 13 - 0
SqlSugar.BzTDengineCore/SqlSugar.BzTDengineCore.csproj

@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netstandard2.1</TargetFramework>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="SqlSugarCore" Version="5.1.4.114" />
+    <PackageReference Include="TDengine.Ado.Data" Version="1.6.16" />
+  </ItemGroup>
+
+</Project>

+ 24 - 0
SqlSugar.BzTDengineCore/SqlSugar.OdbcCore.nuspec

@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>SqlSugar.TDengineCore</id>
+    <version>2.3</version>
+    <authors>sunkaixuan</authors>
+    <owners>Landa</owners>
+    <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
+    <projectUrl>https://github.com/sunkaixuan/SqlSugar</projectUrl>
+    <iconUrl>https://secure.gravatar.com/avatar/a82c03402497b2e58fd65038a3699b30</iconUrl>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <description> SqlSugar TDengine 核心库 </description>
+    <copyright>Copyright 2016</copyright>
+    <tags>TDengine Tdengine tdengine</tags>
+    <dependencies>
+      <group targetFramework=".NETStandard2.1">
+        <dependency id="TDengine.Ado.Data" version="1.6.16" />
+      </group>
+    </dependencies>
+  </metadata>
+  <files>
+    <file src="G:\Git\SqlSugar\Src\Asp.NetCore2\SqlSugar.TDengineCore\bin\Debug\netstandard2.1\SqlSugar.TDengineCore.dll" target="lib\netstandard2.1"></file>
+  </files>
+</package>

+ 206 - 0
SqlSugar.BzTDengineCore/TDengine/CodeFirst/TDengineCodeFirst.cs

@@ -0,0 +1,206 @@
+using SqlSugar;
+using SqlSugar.TDengine;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+
+namespace SqlSugar.BzTDengineCore.TDengine.CodeFirst
+{
+    public class TDengineCodeFirst : CodeFirstProvider
+    {
+        public override void ExistLogic(EntityInfo entityInfo)
+        {
+            if (entityInfo.Columns.HasValue() && entityInfo.IsDisabledUpdateAll == false)
+            {
+                //Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Multiple primary keys do not support modifications");
+
+                var tableName = GetTableName(entityInfo);
+                var dbColumns = Context.DbMaintenance.GetColumnInfosByTableName(tableName, false);
+                ConvertColumns(dbColumns);
+                var entityColumns = entityInfo.Columns.Where(it => it.IsIgnore == false).ToList();
+                var dropColumns = dbColumns
+                                          .Where(dc => !entityColumns.Any(ec => dc.DbColumnName.Equals(ec.OldDbColumnName, StringComparison.CurrentCultureIgnoreCase)))
+                                          .Where(dc => !entityColumns.Any(ec => dc.DbColumnName.Equals(ec.DbColumnName, StringComparison.CurrentCultureIgnoreCase)))
+                                          .ToList();
+                var addColumns = entityColumns
+                                          .Where(ec => ec.OldDbColumnName.IsNullOrEmpty() || !dbColumns.Any(dc => dc.DbColumnName.Equals(ec.OldDbColumnName, StringComparison.CurrentCultureIgnoreCase)))
+                                          .Where(ec => !dbColumns.Any(dc => ec.DbColumnName.Equals(dc.DbColumnName, StringComparison.CurrentCultureIgnoreCase))).ToList();
+
+                var renameColumns = entityColumns
+                    .Where(it => !string.IsNullOrEmpty(it.OldDbColumnName))
+                    .Where(entityColumn => dbColumns.Any(dbColumn => entityColumn.OldDbColumnName.Equals(dbColumn.DbColumnName, StringComparison.CurrentCultureIgnoreCase)))
+                    .ToList();
+
+                var isMultiplePrimaryKey = dbColumns.Where(it => it.IsPrimarykey).Count() > 1 || entityColumns.Where(it => it.IsPrimarykey).Count() > 1;
+
+                var isChange = false;
+                foreach (var item in addColumns)
+                {
+                    Context.DbMaintenance.AddColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
+                    isChange = true;
+                }
+                if (entityInfo.IsDisabledDelete == false)
+                {
+                    foreach (var item in dropColumns)
+                    {
+                        Context.DbMaintenance.DropColumn(tableName, item.DbColumnName);
+                        isChange = true;
+                    }
+                }
+                //foreach (var item in alterColumns)
+                //{
+                //    if (this.Context.CurrentConnectionConfig.DbType == DbType.Oracle)
+                //    {
+                //        var entityColumnItem = entityColumns.FirstOrDefault(y => y.DbColumnName == item.DbColumnName);
+                //        if (entityColumnItem != null && !string.IsNullOrEmpty(entityColumnItem.DataType))
+                //        {
+                //            continue;
+                //        }
+                //    }
+
+                //    this.Context.DbMaintenance.UpdateColumn(tableName, EntityColumnToDbColumn(entityInfo, tableName, item));
+                //    isChange = true;
+                //}
+                foreach (var item in renameColumns)
+                {
+                    Context.DbMaintenance.RenameColumn(tableName, item.OldDbColumnName, item.DbColumnName);
+                    isChange = true;
+                }
+                //var isAddPrimaryKey = false;
+                //foreach (var item in entityColumns)
+                //{
+                //    var dbColumn = dbColumns.FirstOrDefault(dc => dc.DbColumnName.Equals(item.DbColumnName, StringComparison.CurrentCultureIgnoreCase));
+                //    if (dbColumn == null) continue;
+                //    bool pkDiff, idEntityDiff;
+                //    KeyAction(item, dbColumn, out pkDiff, out idEntityDiff);
+                //    if (dbColumn != null && pkDiff && !idEntityDiff && isMultiplePrimaryKey == false)
+                //    {
+                //        var isAdd = item.IsPrimarykey;
+                //        if (isAdd)
+                //        {
+                //            isAddPrimaryKey = true;
+                //            this.Context.DbMaintenance.AddPrimaryKey(tableName, item.DbColumnName);
+                //        }
+                //        else
+                //        {
+                //            this.Context.DbMaintenance.DropConstraint(tableName, string.Format("PK_{0}_{1}", tableName, item.DbColumnName));
+                //        }
+                //    }
+                //    else if ((pkDiff || idEntityDiff) && isMultiplePrimaryKey == false)
+                //    {
+                //        ChangeKey(entityInfo, tableName, item);
+                //    }
+                //}
+                //if (isAddPrimaryKey == false && entityColumns.Count(it => it.IsPrimarykey) == 1 && dbColumns.Count(it => it.IsPrimarykey) == 0)
+                //{
+                //    //var addPk = entityColumns.First(it => it.IsPrimarykey);
+                //    //this.Context.DbMaintenance.AddPrimaryKey(tableName, addPk.DbColumnName);
+                //}
+                //if (isMultiplePrimaryKey)
+                //{
+                //    var oldPkNames = dbColumns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName.ToLower()).OrderBy(it => it).ToList();
+                //    var newPkNames = entityColumns.Where(it => it.IsPrimarykey).Select(it => it.DbColumnName.ToLower()).OrderBy(it => it).ToList();
+                //    if (!Enumerable.SequenceEqual(oldPkNames, newPkNames))
+                //    {
+                //        Check.Exception(true, ErrorMessage.GetThrowMessage("Modification of multiple primary key tables is not supported. Delete tables while creating", "不支持修改多主键表,请删除表在创建"));
+                //    }
+
+                //}
+                if (isChange && IsBackupTable)
+                {
+                    Context.DbMaintenance.BackupTable(tableName, tableName + DateTime.Now.ToString("yyyyMMddHHmmss"), MaxBackupDataRows);
+                }
+                ExistLogicEnd(entityColumns);
+            }
+        }
+
+        public override void NoExistLogic(EntityInfo entityInfo)
+        {
+            List<DbColumnInfo> dbColumns = new List<DbColumnInfo>();
+            foreach (var item in entityInfo.Columns.Where(it => it.PropertyName != "TagsTypeId").OrderBy(it => it.UnderType == typeof(DateTime) ? 0 : 1))
+            {
+                var addItem = EntityColumnToDbColumn(entityInfo, entityInfo.DbTableName, item);
+                dbColumns.Add(addItem);
+            }
+            Context.DbMaintenance.CreateTable(entityInfo.DbTableName, dbColumns);
+        }
+
+        protected override DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
+        {
+            DbColumnInfo result = new DbColumnInfo() { Length = item.Length, DecimalDigits = item.DecimalDigits, Scale = item.DecimalDigits, TableName = tableName, DbColumnName = item.DbColumnName, DataType = item.DataType };
+            if (result.DataType.IsNullOrEmpty())
+            {
+                result.DataType = GetDatabaseTypeName(item.UnderType.Name);
+            }
+            return result;
+        }
+
+        public string GetDatabaseTypeName(string typeName)
+        {
+            switch (typeName.ToLower())
+            {
+                case "bool":
+                    return "BOOL";
+
+                case "datetime":
+                    return "TIMESTAMP";
+
+                case "boolean":
+                    return "BOOL";
+
+                case "byte":
+                    return "TINYINT UNSIGNED";
+
+                case "sbyte":
+                    return "TINYINT";
+
+                case "char":
+                    return "NCHAR";
+
+                case "decimal":
+                    return "FLOAT";
+
+                case "double":
+                    return "DOUBLE";
+
+                case "float":
+                    return "FLOAT";
+
+                case "int":
+                    return "INT";
+
+                case "int32":
+                    return "INT";
+
+                case "int16":
+                    return "INT";
+
+                case "int64":
+                    return "BIGINT";
+
+                case "uint":
+                    return "INT UNSIGNED";
+
+                case "long":
+                    return "BIGINT";
+
+                case "ulong":
+                    return "BIGINT UNSIGNED";
+
+                case "short":
+                    return "SMALLINT";
+
+                case "ushort":
+                    return "SMALLINT UNSIGNED";
+
+                case "string":
+                    return "VARCHAR";
+                // 添加其他类型的映射关系
+
+                default:
+                    return "VARCHAR"; // 如果未识别到类型,则返回原始类型名称
+            }
+        }
+    }
+}

+ 109 - 0
SqlSugar.BzTDengineCore/TDengine/DbBind/TDengineDbBind.cs

@@ -0,0 +1,109 @@
+using SqlSugar;
+using SqlSugar.BzTDengineCore.Tools;
+using SqlSugar.TDengine;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace SqlSugar.BzTDengineCore.TDengine.DbBind
+{
+    public class TDengineDbBind : DbBindProvider
+    {
+        public override string GetDbTypeName(string csharpTypeName)
+        {
+            if (csharpTypeName == UtilConstants.ByteArrayType.Name)
+                return "bytea";
+            if (csharpTypeName.ToLower() == "int32")
+                csharpTypeName = "int";
+            if (csharpTypeName.ToLower() == "int16")
+                csharpTypeName = "short";
+            if (csharpTypeName.ToLower() == "int64")
+                csharpTypeName = "long";
+            if (csharpTypeName.ToLower().IsIn("boolean", "bool"))
+                csharpTypeName = "bool";
+            if (csharpTypeName == "DateTimeOffset")
+                csharpTypeName = "DateTime";
+            var mappings = MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)).ToList();
+            if (mappings != null && mappings.Count > 0)
+                return mappings.First().Key;
+            else
+                return "varchar";
+        }
+
+        public override string GetPropertyTypeName(string dbTypeName)
+        {
+            if (dbTypeName.ToLower() == "int32")
+            {
+                dbTypeName = "int";
+            }
+            else if (dbTypeName.ToLower() == "int16")
+            {
+                dbTypeName = "short";
+            }
+            else if (dbTypeName.ToLower() == "int64")
+            {
+                dbTypeName = "long";
+            }
+            else if (dbTypeName.ToLower() == "string")
+            {
+                dbTypeName = "string";
+            }
+            else if (dbTypeName.ToLower() == "boolean")
+            {
+                dbTypeName = "bool";
+            }
+            else if (dbTypeName.ToLower() == "sbyte")
+            {
+                dbTypeName = "sbyte";
+            }
+            else if (dbTypeName.ToLower() == "double")
+            {
+                dbTypeName = "double";
+            }
+            return dbTypeName;
+        }
+
+        public override List<KeyValuePair<string, CSharpDataType>> MappingTypes
+        {
+            get
+            {
+                var extService = Context.CurrentConnectionConfig.ConfigureExternalServices;
+                if (extService != null && extService.AppendDataReaderTypeMappings.HasValue())
+                {
+                    return extService.AppendDataReaderTypeMappings.Union(MappingTypesConst).ToList();
+                }
+                else
+                {
+                    return MappingTypesConst;
+                }
+            }
+        }
+
+        public static List<KeyValuePair<string, CSharpDataType>> MappingTypesConst = new List<KeyValuePair<string, CSharpDataType>>(){
+                    new KeyValuePair<string, CSharpDataType>("BOOL",CSharpDataType.@bool),
+                    new KeyValuePair<string, CSharpDataType>("TINYINT",CSharpDataType.@byte),
+                    new KeyValuePair<string, CSharpDataType>("SMALLINT",CSharpDataType.@short),
+                    new KeyValuePair<string, CSharpDataType>("INT",CSharpDataType.@int),
+                    new KeyValuePair<string, CSharpDataType>("BIGINT",CSharpDataType.@long),
+                    new KeyValuePair<string, CSharpDataType>("TINYINT UNSIGNED",CSharpDataType.@byte),
+                    new KeyValuePair<string, CSharpDataType>("SMALLINT UNSIGNED",CSharpDataType.@short),
+                    new KeyValuePair<string, CSharpDataType>("INT UNSIGNED",CSharpDataType.@int),
+                    new KeyValuePair<string, CSharpDataType>("BIGINT UNSIGNED",CSharpDataType.@long),
+                    new KeyValuePair<string, CSharpDataType>("FLOAT",CSharpDataType.Single),
+                    new KeyValuePair<string, CSharpDataType>("DOUBLE",CSharpDataType.@double),
+                    new KeyValuePair<string, CSharpDataType>("float8",CSharpDataType.@double),
+                    new KeyValuePair<string, CSharpDataType>("BINARY",CSharpDataType.@string),
+                    new KeyValuePair<string, CSharpDataType>("TIMESTAMP",CSharpDataType.DateTime),
+                    new KeyValuePair<string, CSharpDataType>("NCHAR",CSharpDataType.@string),
+                    new KeyValuePair<string, CSharpDataType>("JSON",CSharpDataType.@string)
+                };
+
+        public override List<string> StringThrow
+        {
+            get
+            {
+                return new List<string>() { "int32", "datetime", "decimal", "double", "byte" };
+            }
+        }
+    }
+}

+ 6 - 0
SqlSugar.BzTDengineCore/TDengine/DbFirst/TDengineDbFirst.cs

@@ -0,0 +1,6 @@
+namespace SqlSugar.BzTDengineCore.TDengine.DbFirst
+{
+    public class TDengineDbFirst : DbFirstProvider
+    {
+    }
+}

+ 558 - 0
SqlSugar.BzTDengineCore/TDengine/DbMaintenance/TDengineDbMaintenance.cs

@@ -0,0 +1,558 @@
+using SqlSugar;
+using SqlSugar.TDengine;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+
+namespace SqlSugar.BzTDengineCore.TDengine.DbMaintenance
+{
+    public class TDengineDbMaintenance : DbMaintenanceProvider
+    {
+        #region DML
+
+        protected override string GetViewInfoListSql => throw new NotImplementedException();
+
+        protected override string GetDataBaseSql
+        {
+            get
+            {
+                return "show databases";
+            }
+        }
+
+        protected override string GetColumnInfosByTableNameSql
+        {
+            get
+            {
+                throw new NotSupportedException("TDengineCode暂时不支持DbFirst等方法,还在开发");
+            }
+        }
+
+        protected override string GetTableInfoListSql
+        {
+            get
+            {
+                var dt = GetSTables();
+                List<string> sb = new List<string>();
+                foreach (DataRow item in dt.Rows)
+                {
+                    sb.Add($" SELECT '{item["stable_name"].ObjToString().ToSqlFilter()}' AS NAME ");
+                }
+                var dt2 = GetTables();
+                foreach (DataRow item in dt2.Rows)
+                {
+                    sb.Add($" SELECT '{item["table_name"].ObjToString().ToSqlFilter()}' AS NAME ");
+                }
+                var result = string.Join(" UNION ALL ", sb);
+                if (string.IsNullOrEmpty(result))
+                {
+                    result = " SELECT 'NoTables' AS Name ";
+                }
+                return result;
+            }
+        }
+
+        #endregion DML
+
+        #region DDL
+
+        protected override string CreateDataBaseSql
+        {
+            get
+            {
+                return "CREATE DATABASE IF NOT EXISTS {0} WAL_RETENTION_PERIOD 3600";
+            }
+        }
+
+        protected override string AddPrimaryKeySql
+        {
+            get
+            {
+                return "ALTER TABLE {0} ADD PRIMARY KEY({2}) /*{1}*/";
+            }
+        }
+
+        protected override string AddColumnToTableSql
+        {
+            get
+            {
+                return "ALTER TABLE {0} ADD COLUMN {1} {2}{3} {4} {5} {6}";
+            }
+        }
+
+        protected override string AlterColumnToTableSql
+        {
+            get
+            {
+                return "alter table {0} MODIFY COLUMN {1} {2}{3} {4} {5} {6}";
+            }
+        }
+
+        protected override string BackupDataBaseSql
+        {
+            get
+            {
+                return "mysqldump.exe  {0} -uroot -p > {1}  ";
+            }
+        }
+
+        protected override string CreateTableSql
+        {
+            get
+            {
+                return "CREATE STABLE IF NOT EXISTS  {0}(\r\n{1} ) TAGS(" + SqlBuilder.GetTranslationColumnName("TagsTypeId") + " VARCHAR(20))";
+            }
+        }
+
+        protected override string CreateTableColumn
+        {
+            get
+            {
+                return "{0} {1}{2} {3} {4} {5}";
+            }
+        }
+
+        protected override string TruncateTableSql
+        {
+            get
+            {
+                return "TRUNCATE TABLE {0}";
+            }
+        }
+
+        protected override string BackupTableSql
+        {
+            get
+            {
+                return "create table {0} as (select * from {1} limit {2} offset 0)";
+            }
+        }
+
+        protected override string DropTableSql
+        {
+            get
+            {
+                return "DROP TABLE {0}";
+            }
+        }
+
+        protected override string DropColumnToTableSql
+        {
+            get
+            {
+                return "ALTER TABLE {0} DROP COLUMN {1}";
+            }
+        }
+
+        protected override string DropConstraintSql
+        {
+            get
+            {
+                return "ALTER TABLE {0} DROP CONSTRAINT {1}";
+            }
+        }
+
+        protected override string RenameColumnSql
+        {
+            get
+            {
+                return "ALTER TABLE {0} RENAME {1} TO {2}";
+            }
+        }
+
+        protected override string AddColumnRemarkSql => "comment on column {1}.{0} is '{2}'";
+
+        protected override string DeleteColumnRemarkSql => "comment on column {1}.{0} is ''";
+
+        protected override string IsAnyColumnRemarkSql
+        { get { throw new NotSupportedException(); } }
+
+        protected override string AddTableRemarkSql => "comment on table {0} is '{1}'";
+
+        protected override string DeleteTableRemarkSql => "comment on table {0} is ''";
+
+        protected override string IsAnyTableRemarkSql
+        { get { throw new NotSupportedException(); } }
+
+        protected override string RenameTableSql => "alter table  {0} to {1}";
+
+        protected override string CreateIndexSql
+        {
+            get
+            {
+                return "CREATE {3} INDEX Index_{0}_{2} ON {0} ({1})";
+            }
+        }
+
+        protected override string AddDefaultValueSql
+        {
+            get
+            {
+                return "ALTER TABLE {0} ALTER COLUMN {1} SET DEFAULT {2}";
+            }
+        }
+
+        protected override string IsAnyIndexSql
+        {
+            get
+            {
+                return "  SELECT count(1) WHERE upper('{0}') IN ( SELECT upper(indexname) FROM pg_indexes )";
+            }
+        }
+
+        protected override string IsAnyProcedureSql => throw new NotImplementedException();
+
+        #endregion DDL
+
+        #region Check
+
+        protected override string CheckSystemTablePermissionsSql
+        {
+            get
+            {
+                return "SHOW DATABASES";
+            }
+        }
+
+        #endregion Check
+
+        #region Scattered
+
+        protected override string CreateTableNull
+        {
+            get
+            {
+                return " ";
+            }
+        }
+
+        protected override string CreateTableNotNull
+        {
+            get
+            {
+                return " ";
+            }
+        }
+
+        protected override string CreateTablePirmaryKey
+        {
+            get
+            {
+                return "PRIMARY KEY";
+            }
+        }
+
+        protected override string CreateTableIdentity
+        {
+            get
+            {
+                return "serial";
+            }
+        }
+
+        #endregion Scattered
+
+        #region Methods
+
+        public override bool AddColumn(string tableName, DbColumnInfo columnInfo)
+        {
+            if (columnInfo.DbColumnName == "TagsTypeId")
+            {
+                return true;
+            }
+            tableName = SqlBuilder.GetTranslationTableName(tableName);
+            var isAddNotNUll = columnInfo.IsNullable == false && columnInfo.DefaultValue.HasValue();
+            if (isAddNotNUll)
+            {
+                columnInfo = Context.Utilities.TranslateCopy(columnInfo);
+                columnInfo.IsNullable = true;
+            }
+            string sql = GetAddColumnSql(tableName, columnInfo);
+            Context.Ado.ExecuteCommand(sql);
+            return true;
+        }
+
+        public override List<DbTableInfo> GetViewInfoList(bool isCache = true)
+        {
+            return new List<DbTableInfo>();
+        }
+
+        public override bool CreateDatabase(string databaseName, string databaseDirectory = null)
+        {
+            var db = Context.CopyNew();
+            db.Ado.Connection.ChangeDatabase("");
+            var sql = CreateDataBaseSql;
+            if (Context.CurrentConnectionConfig.ConnectionString.ToLower().Contains("config_us"))
+            {
+                sql += " PRECISION 'us'";
+            }
+            else if (Context.CurrentConnectionConfig.ConnectionString.ToLower().Contains("config_ns"))
+            {
+                sql += " PRECISION 'ns'";
+            }
+            db.Ado.ExecuteCommand(string.Format(sql, databaseName));
+            return true;
+        }
+
+        public override List<string> GetIndexList(string tableName)
+        {
+            var sql = $"SELECT indexname, indexdef FROM pg_indexes WHERE upper(tablename) = upper('{tableName}')";
+            return Context.Ado.SqlQuery<string>(sql);
+        }
+
+        public override List<string> GetProcList(string dbName)
+        {
+            var sql = $"SELECT proname FROM pg_proc p JOIN pg_namespace n ON p.pronamespace = n.oid WHERE n.nspname = '{dbName}'";
+            return Context.Ado.SqlQuery<string>(sql);
+        }
+
+        public override bool AddDefaultValue(string tableName, string columnName, string defaultValue)
+        {
+            return base.AddDefaultValue(SqlBuilder.GetTranslationTableName(tableName), SqlBuilder.GetTranslationTableName(columnName), defaultValue);
+        }
+
+        public override bool AddColumnRemark(string columnName, string tableName, string description)
+        {
+            tableName = SqlBuilder.GetTranslationTableName(tableName);
+            string sql = string.Format(AddColumnRemarkSql, SqlBuilder.GetTranslationColumnName(columnName.ToLower(isAutoToLowerCodeFirst)), tableName, description);
+            Context.Ado.ExecuteCommand(sql);
+            return true;
+        }
+
+        public override bool AddTableRemark(string tableName, string description)
+        {
+            tableName = SqlBuilder.GetTranslationTableName(tableName);
+            return base.AddTableRemark(tableName, description);
+        }
+
+        public override bool UpdateColumn(string tableName, DbColumnInfo columnInfo)
+        {
+            tableName = SqlBuilder.GetTranslationTableName(tableName);
+            var columnName = SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
+            string sql = GetUpdateColumnSql(tableName, columnInfo);
+            Context.Ado.ExecuteCommand(sql);
+            var isnull = columnInfo.IsNullable ? " DROP NOT NULL " : " SET NOT NULL ";
+            Context.Ado.ExecuteCommand(string.Format("alter table {0} alter {1} {2}", tableName, columnName, isnull));
+            return true;
+        }
+
+        protected override string GetUpdateColumnSql(string tableName, DbColumnInfo columnInfo)
+        {
+            string columnName = SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
+            tableName = SqlBuilder.GetTranslationTableName(tableName);
+            string dataSize = GetSize(columnInfo);
+            string dataType = columnInfo.DataType;
+            //if (!string.IsNullOrEmpty(dataType))
+            //{
+            //    dataType = " type " + dataType;
+            //}
+            string nullType = "";
+            string primaryKey = null;
+            string identity = null;
+            string result = string.Format(AlterColumnToTableSql, tableName, columnName, dataType, dataSize, nullType, primaryKey, identity);
+            return result;
+        }
+
+        public override bool AddRemark(EntityInfo entity)
+        {
+            var db = Context;
+            var columns = entity.Columns.Where(it => it.IsIgnore == false).ToList();
+
+            foreach (var item in columns)
+            {
+                if (item.ColumnDescription != null)
+                {
+                    db.DbMaintenance.AddColumnRemark(item.DbColumnName, item.DbTableName, item.ColumnDescription);
+                }
+            }
+            //table remak
+            if (entity.TableDescription != null)
+            {
+                db.DbMaintenance.AddTableRemark(entity.DbTableName, entity.TableDescription);
+            }
+            return true;
+        }
+
+        public override bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true)
+        {
+            if (columns.HasValue())
+            {
+                foreach (var item in columns)
+                {
+                    if (item.DbColumnName.Equals("GUID", StringComparison.CurrentCultureIgnoreCase) && item.Length == 0)
+                    {
+                        item.Length = 10;
+                    }
+                }
+            }
+            string sql = GetCreateTableSql(tableName, columns);
+            string primaryKeyInfo = null;
+            if (columns.Any(it => it.IsPrimarykey) && isCreatePrimaryKey)
+            {
+                primaryKeyInfo = string.Format(", Primary key({0})", string.Join(",", columns.Where(it => it.IsPrimarykey).Select(it => SqlBuilder.GetTranslationColumnName(it.DbColumnName.ToLower(isAutoToLowerCodeFirst)))));
+            }
+            sql = sql.Replace("$PrimaryKey", primaryKeyInfo);
+            Context.Ado.ExecuteCommand(sql);
+            return true;
+        }
+
+        protected override string GetCreateTableSql(string tableName, List<DbColumnInfo> columns)
+        {
+            List<string> columnArray = new List<string>();
+            Check.Exception(columns.IsNullOrEmpty(), "No columns found ");
+            foreach (var item in columns)
+            {
+                string columnName = item.DbColumnName;
+                string dataType = item.DataType;
+                if (dataType == "varchar" && item.Length == 0)
+                {
+                    item.Length = 1;
+                }
+                //if (dataType == "uuid")
+                //{
+                //    item.Length = 50;
+                //    dataType = "varchar";
+                //}
+                string dataSize = item.Length > 0 ? string.Format("({0})", item.Length) : null;
+                //if (item.DecimalDigits > 0&&item.Length>0 && dataType?.ToLower()== "float")
+                //{
+                //    item.Length = 0;
+                //    dataSize = $"({item.Length},{item.DecimalDigits})";
+                //}
+                //if (item.DecimalDigits > 0 && item.Length > 0 && dataType?.ToLower() ==  "double")
+                //{
+                //    dataSize = $"({item.Length},{item.DecimalDigits})";
+                //}
+                //if (item.DecimalDigits > 0 && item.Length > 0 && dataType?.ToLower() == "decimal")
+                //{
+                //    dataSize = $"({item.Length},{item.DecimalDigits})";
+                //}
+                //if (item.DecimalDigits == 0 && item.Length == 0 && dataType?.ToLower() == "float")
+                //{
+                //   dataType = $"FLOAT(18,4)";
+                //}
+                //if (item.DecimalDigits == 0 && item.Length == 0 && dataType?.ToLower() == "double")
+                //{
+                //    dataType = $"DOUBLE(18,4)";
+                //}
+                if (item.Length == 0 && dataType?.ToLower()?.IsIn("nchar", "varchar") == true)
+                {
+                    dataType = "VARCHAR(200)";
+                }
+                if (dataType?.ToLower()?.IsIn("float", "double") == true)
+                {
+                    dataSize = null;
+                }
+                string primaryKey = null;
+                string addItem = string.Format(CreateTableColumn, SqlBuilder.GetTranslationColumnName(columnName.ToLower(isAutoToLowerCodeFirst)), dataType, dataSize, null, primaryKey, "");
+                columnArray.Add(addItem);
+            }
+            string tableString = string.Format(CreateTableSql, SqlBuilder.GetTranslationTableName("STable_" + tableName.ToLower(isAutoToLowerCodeFirst)), string.Join(",\r\n", columnArray));
+            var childTableName = SqlBuilder.GetTranslationTableName(tableName.ToLower(isAutoToLowerCodeFirst));
+            var stableName = SqlBuilder.GetTranslationTableName("STable_" + tableName.ToLower(isAutoToLowerCodeFirst));
+            Context.Ado.ExecuteCommand(tableString);
+            var createChildSql = $"CREATE TABLE IF NOT EXISTS     {childTableName} USING {stableName} TAGS('default')";
+            Context.Ado.ExecuteCommand(createChildSql);
+            return tableString;
+        }
+
+        public override bool IsAnyConstraint(string constraintName)
+        {
+            throw new NotSupportedException("PgSql IsAnyConstraint NotSupportedException");
+        }
+
+        public override bool BackupDataBase(string databaseName, string fullFileName)
+        {
+            Check.ThrowNotSupportedException("PgSql BackupDataBase NotSupported");
+            return false;
+        }
+
+        public override List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true)
+        {
+            var sql = $"select * from {SqlBuilder.GetTranslationColumnName(tableName)} where 1=2 ";
+            List<DbColumnInfo> result = new List<DbColumnInfo>();
+            DataTable dt = null;
+            try
+            {
+                dt = Context.Ado.GetDataTable(sql);
+            }
+            catch (Exception)
+            {
+                sql = $"select * from `{tableName}` where 1=2 ";
+                dt = Context.Ado.GetDataTable(sql);
+            }
+            foreach (DataColumn item in dt.Columns)
+            {
+                var addItem = new DbColumnInfo()
+                {
+                    DbColumnName = item.ColumnName,
+                    DataType = item.DataType.Name
+                };
+                result.Add(addItem);
+            }
+            if (result.Count(it => it.DataType == "DateTime") == 1)
+            {
+                result.First(it => it.DataType == "DateTime").IsPrimarykey = true;
+            }
+            return result;
+        }
+
+        #endregion Methods
+
+        #region Helper
+
+        private bool isAutoToLowerCodeFirst
+        {
+            get
+            {
+                if (Context.CurrentConnectionConfig.MoreSettings == null) return true;
+                else if (
+                    Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower == false &&
+                    Context.CurrentConnectionConfig.MoreSettings?.PgSqlIsAutoToLowerCodeFirst == false)
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+        }
+
+        private string GetSchema()
+        {
+            var schema = "public";
+            if (System.Text.RegularExpressions.Regex.IsMatch(Context.CurrentConnectionConfig.ConnectionString.ToLower(), "searchpath="))
+            {
+                var regValue = System.Text.RegularExpressions.Regex.Match(Context.CurrentConnectionConfig.ConnectionString.ToLower(), @"searchpath\=(\w+)").Groups[1].Value;
+                if (regValue.HasValue())
+                {
+                    schema = regValue;
+                }
+            }
+            else if (System.Text.RegularExpressions.Regex.IsMatch(Context.CurrentConnectionConfig.ConnectionString.ToLower(), "search path="))
+            {
+                var regValue = System.Text.RegularExpressions.Regex.Match(Context.CurrentConnectionConfig.ConnectionString.ToLower(), @"search path\=(\w+)").Groups[1].Value;
+                if (regValue.HasValue())
+                {
+                    schema = regValue;
+                }
+            }
+
+            return schema;
+        }
+
+        private DataTable GetTables()
+        {
+            return Context.Ado.GetDataTable("SHOW TABLES");
+        }
+
+        private DataTable GetSTables()
+        {
+            return Context.Ado.GetDataTable("SHOW STABLES");
+        }
+
+        #endregion Helper
+    }
+}

+ 99 - 0
SqlSugar.BzTDengineCore/TDengine/Insertable/TDengineInserttable.cs

@@ -0,0 +1,99 @@
+using SqlSugar;
+using SqlSugar.TDengine;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SqlSugar.BzTDengineCore.TDengine.Insertable
+{
+    public class TDengineInsertable<T> : InsertableProvider<T> where T : class, new()
+    {
+        public override int ExecuteReturnIdentity()
+        {
+            InsertBuilder.IsReturnIdentity = true;
+            PreToSql();
+            string identityColumn = GetIdentityColumn();
+            string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", SqlBuilder.GetTranslationColumnName(identityColumn));
+            RestoreMapping();
+            var result = Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()).ObjToInt();
+            After(sql, result);
+            return result;
+        }
+
+        public override async Task<int> ExecuteReturnIdentityAsync()
+        {
+            InsertBuilder.IsReturnIdentity = true;
+            PreToSql();
+            string identityColumn = GetIdentityColumn();
+            string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", SqlBuilder.GetTranslationColumnName(identityColumn));
+            RestoreMapping();
+            var obj = await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
+            var result = obj.ObjToInt();
+            After(sql, result);
+            return result;
+        }
+
+        public override KeyValuePair<string, List<SugarParameter>> ToSql()
+        {
+            var result = base.ToSql();
+            var primaryKey = GetPrimaryKeys().FirstOrDefault();
+            if (primaryKey != null)
+            {
+                primaryKey = SqlBuilder.GetTranslationColumnName(primaryKey);
+            }
+            return new KeyValuePair<string, List<SugarParameter>>(result.Key.Replace("$PrimaryKey", primaryKey), result.Value);
+        }
+
+        public override long ExecuteReturnBigIdentity()
+        {
+            InsertBuilder.IsReturnIdentity = true;
+            PreToSql();
+            string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", SqlBuilder.GetTranslationColumnName(GetIdentityKeys().FirstOrDefault()));
+            RestoreMapping();
+            var result = Convert.ToInt64(Ado.GetScalar(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
+            After(sql, result);
+            return result;
+        }
+
+        public override async Task<long> ExecuteReturnBigIdentityAsync()
+        {
+            InsertBuilder.IsReturnIdentity = true;
+            PreToSql();
+            string sql = InsertBuilder.ToSqlString().Replace("$PrimaryKey", SqlBuilder.GetTranslationColumnName(GetIdentityKeys().FirstOrDefault()));
+            RestoreMapping();
+            var result = Convert.ToInt64(await Ado.GetScalarAsync(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray()) ?? "0");
+            After(sql, result);
+            return result;
+        }
+
+        public override bool ExecuteCommandIdentityIntoEntity()
+        {
+            var result = InsertObjs.First();
+            var identityKeys = GetIdentityKeys();
+            if (identityKeys.Count == 0) { return ExecuteCommand() > 0; }
+            var idValue = ExecuteReturnBigIdentity();
+            Check.Exception(identityKeys.Count > 1, "ExecuteCommandIdentityIntoEntity does not support multiple identity keys");
+            var identityKey = identityKeys.First();
+            object setValue = 0;
+            if (idValue > int.MaxValue)
+                setValue = idValue;
+            else
+                setValue = Convert.ToInt32(idValue);
+            var propertyName = Context.EntityMaintenance.GetPropertyName<T>(identityKey);
+            typeof(T).GetProperties().First(t => t.Name.ToUpper() == propertyName.ToUpper()).SetValue(result, setValue, null);
+            return idValue > 0;
+        }
+
+        private string GetIdentityColumn()
+        {
+            var identityColumn = GetIdentityKeys().FirstOrDefault();
+            if (identityColumn == null)
+            {
+                var columns = Context.DbMaintenance.GetColumnInfosByTableName(InsertBuilder.GetTableNameString);
+                identityColumn = columns.First(it => it.IsIdentity || it.IsPrimarykey).DbColumnName;
+            }
+            return identityColumn;
+        }
+    }
+}

+ 64 - 0
SqlSugar.BzTDengineCore/TDengine/Queryable/TDengineSqlQueryable.cs

@@ -0,0 +1,64 @@
+namespace SqlSugar.BzTDengineCore.TDengine.Queryable
+{
+    public class TDengineQueryable<T> : QueryableProvider<T>
+    {
+        public override ISugarQueryable<T> With(string withString)
+        {
+            return this;
+        }
+
+        public override ISugarQueryable<T> PartitionBy(string groupFileds)
+        {
+            GroupBy(groupFileds);
+            return this;
+        }
+    }
+
+    public class TDengineQueryable<T, T2> : QueryableProvider<T, T2>
+    {
+        public new ISugarQueryable<T, T2> With(string withString)
+        {
+            return this;
+        }
+    }
+
+    public class TDengineQueryable<T, T2, T3> : QueryableProvider<T, T2, T3>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4> : QueryableProvider<T, T2, T3, T4>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4, T5> : QueryableProvider<T, T2, T3, T4, T5>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4, T5, T6> : QueryableProvider<T, T2, T3, T4, T5, T6>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4, T5, T6, T7> : QueryableProvider<T, T2, T3, T4, T5, T6, T7>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4, T5, T6, T7, T8> : QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> : QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> : QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
+    {
+    }
+
+    public class TDengineQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> : QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
+    {
+    }
+}

+ 143 - 0
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineBuilder.cs

@@ -0,0 +1,143 @@
+using SqlSugar.BzTDengineCore.Tools;
+using SqlSugar.TDengine;
+using System;
+using System.Linq;
+
+namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+{
+    public class TDengineBuilder : SqlBuilderProvider
+    {
+        public override string SqlTranslationLeft
+        {
+            get
+            {
+                return "`";
+            }
+        }
+
+        public override string SqlTranslationRight
+        {
+            get
+            {
+                return "`";
+            }
+        }
+
+        public override string SqlDateNow
+        {
+            get
+            {
+                return "current_date";
+            }
+        }
+
+        public override string FullSqlDateNow
+        {
+            get
+            {
+                return " now() ";
+            }
+        }
+
+        public bool isAutoToLower
+        {
+            get
+            {
+                if (Context.CurrentConnectionConfig.MoreSettings == null) return true;
+                else if (
+                    Context.CurrentConnectionConfig.MoreSettings.PgSqlIsAutoToLower == false &&
+                    Context.CurrentConnectionConfig.MoreSettings?.PgSqlIsAutoToLowerCodeFirst == false)
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+        }
+
+        public override string GetTranslationColumnName(string propertyName)
+        {
+            if (propertyName.Contains(".") && !propertyName.Contains(SqlTranslationLeft))
+            {
+                return string.Join(".", propertyName.Split('.').Select(it => $"{SqlTranslationLeft}{it.ToLower(isAutoToLower)}{SqlTranslationRight}"));
+            }
+
+            if (propertyName.Contains(SqlTranslationLeft)) return propertyName;
+            else
+                return SqlTranslationLeft + propertyName.ToLower(isAutoToLower) + SqlTranslationRight;
+        }
+
+        //public override string GetNoTranslationColumnName(string name)
+        //{
+        //    return name.TrimEnd(Convert.ToChar(SqlTranslationRight)).TrimStart(Convert.ToChar(SqlTranslationLeft)).ToLower();
+        //}
+        public override string GetTranslationColumnName(string entityName, string propertyName)
+        {
+            Check.ArgumentNullException(entityName, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
+            Check.ArgumentNullException(propertyName, string.Format(ErrorMessage.ObjNotExist, "Column Name"));
+            var context = Context;
+            var mappingInfo = context
+                 .MappingColumns
+                 .FirstOrDefault(it =>
+                 it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase) &&
+                 it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
+            return mappingInfo == null ? SqlTranslationLeft + propertyName.ToLower(isAutoToLower) + SqlTranslationRight : SqlTranslationLeft + mappingInfo.DbColumnName.ToLower(isAutoToLower) + SqlTranslationRight;
+        }
+
+        public override string GetTranslationTableName(string name)
+        {
+            Check.ArgumentNullException(name, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
+            var context = Context;
+
+            var mappingInfo = context
+                .MappingTables
+                .FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
+            if (mappingInfo == null && name.Contains(".") && name.Contains("`"))
+            {
+                return name;
+            }
+            name = mappingInfo == null ? name : mappingInfo.DbTableName;
+            if (name.Contains(".") && !name.Contains("(") && !name.Contains("\".\""))
+            {
+                return string.Join(".", name.ToLower(isAutoToLower).Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
+            }
+            else if (name.Contains("("))
+            {
+                return name;
+            }
+            else if (name.Contains(SqlTranslationLeft) && name.Contains(SqlTranslationRight))
+            {
+                return name;
+            }
+            else
+            {
+                return SqlTranslationLeft + name.ToLower(isAutoToLower).TrimEnd('"').TrimStart('"') + SqlTranslationRight;
+            }
+        }
+
+        public override string GetUnionFomatSql(string sql)
+        {
+            return " ( " + sql + " )  ";
+        }
+
+        public override Type GetNullType(string tableName, string columnName)
+        {
+            if (tableName != null)
+                tableName = tableName.Trim();
+            var columnInfo = Context.DbMaintenance.GetColumnInfosByTableName(tableName).FirstOrDefault(z => z.DbColumnName?.ToLower() == columnName?.ToLower());
+            if (columnInfo != null)
+            {
+                var cTypeName = Context.Ado.DbBind.GetCsharpTypeNameByDbTypeName(columnInfo.DataType);
+                var value = UtilMethods.GetTypeByTypeName(cTypeName);
+                if (value != null)
+                {
+                    var key = "GetNullType_" + tableName + columnName;
+                    return new ReflectionInoCacheService().GetOrCreate(key, () => value);
+                }
+            }
+            return null;
+        }
+    }
+}

+ 6 - 0
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineDeleteBuilder.cs

@@ -0,0 +1,6 @@
+namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+{
+    public class TDengineDeleteBuilder : DeleteBuilder
+    {
+    }
+}

+ 459 - 0
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineExpressionContext.cs

@@ -0,0 +1,459 @@
+using SqlSugar;
+using SqlSugar.BzTDengineCore.Tools;
+using SqlSugar.TDengine;
+using System;
+using System.Linq;
+
+namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+{
+    public class TDengineExpressionContext : ExpressionContext, ILambdaExpressions
+    {
+        public SqlSugarProvider Context { get; set; }
+
+        public TDengineExpressionContext()
+        {
+            DbMehtods = new TDengineExpressionContextMethod();
+        }
+
+        public override string SqlTranslationLeft
+        {
+            get
+            {
+                return "`";
+            }
+        }
+
+        public override string SqlTranslationRight
+        {
+            get
+            {
+                return "`";
+            }
+        }
+
+        public override string GetTranslationText(string name)
+        {
+            return SqlTranslationLeft + name.ToLower(isAutoToLower) + SqlTranslationRight;
+        }
+
+        public bool isAutoToLower
+        {
+            get
+            {
+                return PgSqlIsAutoToLower;
+            }
+        }
+
+        public override string GetTranslationTableName(string entityName, bool isMapping = true)
+        {
+            Check.ArgumentNullException(entityName, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
+            if (IsTranslationText(entityName)) return entityName;
+            isMapping = isMapping && MappingTables.HasValue();
+            var isComplex = entityName.Contains(UtilConstants.Dot);
+            if (isMapping && isComplex)
+            {
+                var columnInfo = entityName.Split(UtilConstants.DotChar);
+                var mappingInfo = MappingTables.FirstOrDefault(it => it.EntityName.Equals(columnInfo.Last(), StringComparison.CurrentCultureIgnoreCase));
+                if (mappingInfo != null)
+                {
+                    columnInfo[columnInfo.Length - 1] = mappingInfo.EntityName;
+                }
+                return string.Join(UtilConstants.Dot, columnInfo.Select(it => GetTranslationText(it)));
+            }
+            else if (isMapping)
+            {
+                var mappingInfo = MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
+
+                var tableName = mappingInfo?.DbTableName + "";
+                if (tableName.Contains("."))
+                {
+                    tableName = string.Join(UtilConstants.Dot, tableName.Split(UtilConstants.DotChar).Select(it => GetTranslationText(it)));
+                    return tableName;
+                }
+
+                return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.DbTableName).ToLower(isAutoToLower) + SqlTranslationRight;
+            }
+            else if (isComplex)
+            {
+                return string.Join(UtilConstants.Dot, entityName.Split(UtilConstants.DotChar).Select(it => GetTranslationText(it)));
+            }
+            else
+            {
+                return GetTranslationText(entityName);
+            }
+        }
+
+        public override string GetTranslationColumnName(string columnName)
+        {
+            Check.ArgumentNullException(columnName, string.Format(ErrorMessage.ObjNotExist, "Column Name"));
+            if (columnName.Substring(0, 1) == SqlParameterKeyWord)
+            {
+                return columnName;
+            }
+            if (IsTranslationText(columnName)) return columnName;
+            if (columnName.Contains(UtilConstants.Dot))
+            {
+                return string.Join(UtilConstants.Dot, columnName.Split(UtilConstants.DotChar).Select(it => GetTranslationText(it)));
+            }
+            else
+            {
+                return GetTranslationText(columnName);
+            }
+        }
+
+        public override string GetDbColumnName(string entityName, string propertyName)
+        {
+            if (MappingColumns.HasValue())
+            {
+                var mappingInfo = MappingColumns.SingleOrDefault(it => it.EntityName == entityName && it.PropertyName == propertyName);
+                return (mappingInfo == null ? propertyName : mappingInfo.DbColumnName).ToLower(isAutoToLower);
+            }
+            else
+            {
+                return propertyName.ToLower(isAutoToLower);
+            }
+        }
+
+        public string GetValue(object entityValue)
+        {
+            if (entityValue == null)
+                return null;
+            var type = UtilMethods.GetUnderType(entityValue.GetType());
+            if (UtilConstants.NumericalTypes.Contains(type))
+            {
+                return entityValue.ToString();
+            }
+            else if (type == UtilConstants.DateType)
+            {
+                return DbMehtods.ToDate(new MethodCallExpressionModel()
+                {
+                    Args = new System.Collections.Generic.List<MethodCallExpressionArgs>() {
+                 new MethodCallExpressionArgs(){ MemberName=$"'{entityValue}'" }
+                }
+                });
+            }
+            else
+            {
+                return DbMehtods.ToString(new MethodCallExpressionModel()
+                {
+                    Args = new System.Collections.Generic.List<MethodCallExpressionArgs>() {
+                 new MethodCallExpressionArgs(){ MemberName=$"'{entityValue}'" }
+                }
+                });
+            }
+        }
+    }
+
+    public class TDengineExpressionContextMethod : DefaultDbMethod, IDbMethods
+    {
+        public override string CharIndex(MethodCallExpressionModel model)
+        {
+            return string.Format(" (strpos ({1},{0})-1)", model.Args[0].MemberName, model.Args[1].MemberName);
+        }
+
+        public override string TrueValue()
+        {
+            return "true";
+        }
+
+        public override string FalseValue()
+        {
+            return "false";
+        }
+
+        public override string DateDiff(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            var parameter3 = model.Args[2];
+            return string.Format(" TIMEDIFF({1},{2},1{0}) ", parameter.MemberValue.ObjToString().ToLower().First(), parameter2.MemberName, parameter3.MemberName);
+        }
+
+        public override string IIF(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            var parameter3 = model.Args[2];
+            if (parameter.Type == UtilConstants.BoolType)
+            {
+                parameter.MemberName = parameter.MemberName.ToString().Replace("=1", "=true");
+                parameter2.MemberName = false;
+                parameter3.MemberName = true;
+            }
+            return string.Format("( CASE  WHEN {0} THEN {1}  ELSE {2} END )", parameter.MemberName, parameter2.MemberName, parameter3.MemberName);
+        }
+
+        public override string DateValue(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            var format = parameter2.MemberValue.ObjToString();
+            return string.Format("  {0}({1})   ", format, parameter.MemberName);
+        }
+
+        public override string Contains(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            return string.Format(" ({0} like  {1}  ) ", parameter.MemberName, ("%" + parameter2.MemberValue + "%").ToSqlValue());
+        }
+
+        public override string StartsWith(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            return string.Format(" ({0} like  {1}  ) ", parameter.MemberName, ("%" + parameter2.MemberValue).ToSqlValue());
+        }
+
+        public override string EndsWith(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            return string.Format("({0} like  {1}  ) ", parameter.MemberName, (parameter2.MemberValue + "%").ToSqlValue());
+        }
+
+        public override string DateIsSameDay(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            return string.Format(" ( to_char({0},'yyyy-MM-dd')=to_char({1},'yyyy-MM-dd') ) ", parameter.MemberName, parameter2.MemberName); ;
+        }
+
+        public override string HasValue(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format("( {0} IS NOT NULL )", parameter.MemberName);
+        }
+
+        public override string DateIsSameByType(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            var parameter3 = model.Args[2];
+            DateType dateType = (DateType)parameter3.MemberValue;
+            var format = "yyyy-MM-dd";
+            if (dateType == DateType.Quarter)
+            {
+                return string.Format(" (date_trunc('quarter',{0})=date_trunc('quarter',{1}) ) ", parameter.MemberName, parameter2.MemberName, format);
+            }
+            switch (dateType)
+            {
+                case DateType.Year:
+                    format = "yyyy";
+                    break;
+
+                case DateType.Month:
+                    format = "yyyy-MM";
+                    break;
+
+                case DateType.Day:
+                    break;
+
+                case DateType.Hour:
+                    format = "yyyy-MM-dd HH";
+                    break;
+
+                case DateType.Second:
+                    format = "yyyy-MM-dd HH:mm:ss";
+                    break;
+
+                case DateType.Minute:
+                    format = "yyyy-MM-dd HH:mm";
+                    break;
+
+                case DateType.Millisecond:
+                    format = "yyyy-MM-dd HH:mm.ms";
+                    break;
+
+                default:
+                    break;
+            }
+            return string.Format(" ( to_char({0},'{2}')=to_char({1},'{2}') ) ", parameter.MemberName, parameter2.MemberName, format);
+        }
+
+        public override string ToDate(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" CAST({0} AS timestamp)", parameter.MemberName);
+        }
+
+        public override string ToDateShort(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format("  SUBSTR(TO_ISO8601({0}),1,10) ", parameter.MemberName);
+        }
+
+        public override string DateAddByType(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            var parameter3 = model.Args[2];
+            return string.Format(" {1}+{2}{0} ", parameter3.MemberValue.ObjToString().ToLower().First(), parameter.MemberName, parameter2.MemberValue);
+        }
+
+        public override string DateAddDay(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter2 = model.Args[1];
+            return string.Format(" ({0} + ({1}||'day')::INTERVAL) ", parameter.MemberName, parameter2.MemberName);
+        }
+
+        public override string ToInt32(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" CAST({0} AS INT4)", parameter.MemberName);
+        }
+
+        public override string ToInt64(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" CAST({0} AS INT8)", parameter.MemberName);
+        }
+
+        public override string ToString(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" CAST({0} AS VARCHAR)", parameter.MemberName);
+        }
+
+        public override string ToGuid(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" CAST({0} AS UUID)", parameter.MemberName);
+        }
+
+        public override string ToDouble(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" CAST({0} AS DECIMAL(18,4))", parameter.MemberName);
+        }
+
+        public override string ToBool(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" CAST({0} AS boolean)", parameter.MemberName);
+        }
+
+        public override string ToDecimal(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" CAST({0} AS DECIMAL(18,4))", parameter.MemberName);
+        }
+
+        public override string Length(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            return string.Format(" LENGTH({0})", parameter.MemberName);
+        }
+
+        public override string MergeString(params string[] strings)
+        {
+            return " concat(" + string.Join(",", strings).Replace("+", "") + ") ";
+        }
+
+        public override string IsNull(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter1 = model.Args[1];
+            return string.Format("(CASE WHEN  {0} IS NULL THEN  {1} ELSE {0} END)", parameter.MemberName, parameter1.MemberName);
+        }
+
+        public override string GetDate()
+        {
+            return "NOW()";
+        }
+
+        public override string GetRandom()
+        {
+            return "RANDOM()";
+        }
+
+        public override string EqualTrue(string fieldName)
+        {
+            return "( " + fieldName + "=true )";
+        }
+
+        public override string JsonField(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter1 = model.Args[1];
+            //var parameter2 = model.Args[2];
+            //var parameter3= model.Args[3];
+            var result = GetJson(parameter.MemberName, parameter1.MemberName, model.Args.Count() == 2);
+            if (model.Args.Count > 2)
+            {
+                result = GetJson(result, model.Args[2].MemberName, model.Args.Count() == 3);
+            }
+            if (model.Args.Count > 3)
+            {
+                result = GetJson(result, model.Args[3].MemberName, model.Args.Count() == 4);
+            }
+            if (model.Args.Count > 4)
+            {
+                result = GetJson(result, model.Args[4].MemberName, model.Args.Count() == 5);
+            }
+            if (model.Args.Count > 5)
+            {
+                result = GetJson(result, model.Args[5].MemberName, model.Args.Count() == 6);
+            }
+            return result;
+        }
+
+        public override string JsonContainsFieldName(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            var parameter1 = model.Args[1];
+            return $"({parameter.MemberName}::jsonb ?{parameter1.MemberName})";
+        }
+
+        private string GetJson(object memberName1, object memberName2, bool isLast)
+        {
+            if (isLast)
+            {
+                return $"({memberName1}::json->>{memberName2})";
+            }
+            else
+            {
+                return $"({memberName1}->{memberName2})";
+            }
+        }
+
+        public override string JsonArrayLength(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            //var parameter1 = model.Args[1];
+            return $" json_array_length({parameter.MemberName}::json) ";
+        }
+
+        public override string JsonParse(MethodCallExpressionModel model)
+        {
+            var parameter = model.Args[0];
+            //var parameter1 = model.Args[1];
+            return $" ({parameter.MemberName}::json) ";
+        }
+
+        public override string JsonArrayAny(MethodCallExpressionModel model)
+        {
+            if (UtilMethods.IsNumber(model.Args[1].MemberValue.GetType().Name))
+            {
+                return $" {model.Args[0].MemberName}::jsonb @> '[{model.Args[1].MemberValue.ObjToStringNoTrim().ToSqlFilter()}]'::jsonb";
+            }
+            else
+            {
+                return $" {model.Args[0].MemberName}::jsonb @> '[\"{model.Args[1].MemberValue}\"]'::jsonb";
+            }
+        }
+
+        public override string JsonListObjectAny(MethodCallExpressionModel model)
+        {
+            if (UtilMethods.IsNumber(model.Args[2].MemberValue.GetType().Name))
+            {
+                return $" {model.Args[0].MemberName}::jsonb @> '[{{\"{model.Args[1].MemberValue}\":{model.Args[2].MemberValue}}}]'::jsonb";
+            }
+            else
+            {
+                return $" {model.Args[0].MemberName}::jsonb @> '[{{\"{model.Args[1].MemberValue}\":\"{model.Args[2].MemberValue.ObjToStringNoTrim().ToSqlFilter()}\"}}]'::jsonb";
+            }
+        }
+    }
+}

+ 50 - 0
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineFastBuilder.cs

@@ -0,0 +1,50 @@
+using SqlSugar.TDengineAdo;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Threading.Tasks;
+
+namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+{
+    public class TDengineFastBuilder : FastBuilder, IFastBuilder
+    {
+        private EntityInfo entityInfo;
+
+        public TDengineFastBuilder(EntityInfo entityInfo)
+        {
+            this.entityInfo = entityInfo;
+        }
+
+        public override string UpdateSql { get; set; } = @"UPDATE  {1}    SET {0}  FROM   {2}  AS TE  WHERE {3}
+";
+
+        //public virtual async Task<int> UpdateByTempAsync(string tableName, string tempName, string[] updateColumns, string[] whereColumns)
+        //{
+        //    Check.ArgumentNullException(!updateColumns.Any(), "update columns count is 0");
+        //    Check.ArgumentNullException(!whereColumns.Any(), "where columns count is 0");
+        //    var sets = string.Join(",", updateColumns.Select(it => $"TM.{it}=TE.{it}"));
+        //    var wheres = string.Join(",", whereColumns.Select(it => $"TM.{it}=TE.{it}"));
+        //    string sql = string.Format(UpdateSql, sets, tableName, tempName, wheres);
+        //    return await this.Context.Ado.ExecuteCommandAsync(sql);
+        //}
+        public async Task<int> ExecuteBulkCopyAsync(DataTable dt)
+        {
+            return 0;
+        }
+
+        private void BulkCopy(DataTable dt, string copyString, TDengineConnection conn, List<DbColumnInfo> columns)
+        {
+            throw new NotSupportedException();
+        }
+
+        public override async Task<int> UpdateByTempAsync(string tableName, string tempName, string[] updateColumns, string[] whereColumns)
+        {
+            throw new NotSupportedException();
+        }
+
+        public override async Task CreateTempAsync<T>(DataTable dt)
+        {
+            throw new NotSupportedException();
+        }
+    }
+}

+ 186 - 0
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineInsertBuilder.cs

@@ -0,0 +1,186 @@
+using SqlSugar;
+using SqlSugar.BzTDengineCore.Tools;
+using SqlSugar.TDengine;
+using System;
+using System.Linq;
+using System.Text;
+
+namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+{
+    public class TDengineInsertBuilder : InsertBuilder
+    {
+        public override string SqlTemplate
+        {
+            get
+            {
+                if (IsReturnIdentity)
+                {
+                    return @"INSERT INTO {0}
+           ({1})
+     VALUES
+           ({2}) ";
+                }
+                else
+                {
+                    return @"INSERT INTO {0}
+           ({1})
+     VALUES
+           ({2})";
+                }
+            }
+        }
+
+        public override string SqlTemplateBatch => "INSERT INTO {0} ({1})";
+        public override string SqlTemplateBatchUnion => " VALUES ";
+
+        public override string SqlTemplateBatchSelect => " {0} ";
+
+        public override Func<string, string, string> ConvertInsertReturnIdFunc { get; set; } = (name, sql) =>
+        {
+            return sql.Trim().TrimEnd(';') + $"returning {name} ";
+        };
+
+        public override string ToSqlString()
+        {
+            if (IsNoInsertNull)
+            {
+                DbColumnInfoList = DbColumnInfoList.Where(it => it.Value != null).ToList();
+            }
+            var groupList = DbColumnInfoList.GroupBy(it => it.TableId).ToList();
+            var isSingle = groupList.Count() == 1;
+            string columnsString = string.Join(",", groupList.First().Select(it => Builder.GetTranslationColumnName(it.DbColumnName)));
+            if (isSingle)
+            {
+                string columnParametersString = string.Join(",", DbColumnInfoList.Select(it => base.GetDbColumn(it, Builder.SqlParameterKeyWord + it.DbColumnName)));
+                ActionMinDate();
+                return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
+            }
+            else
+            {
+                StringBuilder batchInsetrSql = new StringBuilder();
+                int pageSize = 10000000;
+                int pageIndex = 1;
+                if (IsNoPage && IsReturnPkList)
+                {
+                    pageSize = groupList.Count;
+                }
+                int totalRecord = groupList.Count;
+                int pageCount = (totalRecord + pageSize - 1) / pageSize;
+                while (pageCount >= pageIndex)
+                {
+                    batchInsetrSql.AppendFormat(SqlTemplateBatch, GetTableNameString, columnsString);
+                    int i = 0;
+                    foreach (var columns in groupList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList())
+                    {
+                        var isFirst = i == 0;
+                        if (isFirst)
+                        {
+                            batchInsetrSql.Append(SqlTemplateBatchUnion);
+                        }
+                        batchInsetrSql.Append("\r\n ( " + string.Join(",", columns.Select(it =>
+                        {
+                            if (it.InsertServerTime || it.InsertSql.HasValue() || it.SqlParameterDbType is Type || it?.PropertyType?.Name == "DateOnly" || it?.PropertyType?.Name == "TimeOnly")
+                            {
+                                return GetDbColumn(it, null);
+                            }
+                            object value = null;
+                            if (it?.Value is DateTime)
+                            {
+                                value = it.Value.ObjToDate().ToString("yyyy-MM-dd HH:mm:ss.fff");
+                            }
+                            else if (it?.Value is bool)
+                            {
+                                value = it.Value?.ToString()?.ToLower();
+                            }
+                            else if (it.Value is DateTimeOffset)
+                            {
+                                return FormatDateTimeOffset(it.Value);
+                            }
+                            else if (it.IsArray && it.Value != null)
+                            {
+                                return FormatValue(it.Value, it.PropertyName, i, it);
+                            }
+                            else
+                            {
+                                value = it.Value;
+                            }
+                            if (value == null || value == DBNull.Value)
+                            {
+                                return string.Format(SqlTemplateBatchSelect, "NULL");
+                            }
+                            return string.Format(SqlTemplateBatchSelect, "'" + value.ObjToStringNoTrim().ToSqlFilter() + "'");
+                        })) + "),");
+                        ++i;
+                    }
+                    pageIndex++;
+                    batchInsetrSql.Remove(batchInsetrSql.Length - 1, 1).Append("\r\n;\r\n");
+                }
+                return batchInsetrSql.ToString();
+            }
+        }
+
+        public object FormatValue(object value, string name, int i, DbColumnInfo columnInfo)
+        {
+            if (value == null)
+            {
+                return "NULL";
+            }
+            else
+            {
+                var type = value.GetType();
+                if (type == UtilConstants.DateType || columnInfo.IsArray || columnInfo.IsJson)
+                {
+                    var parameterName = Builder.SqlParameterKeyWord + name + i;
+                    var paramter = new SugarParameter(parameterName, value);
+                    if (columnInfo.IsJson)
+                    {
+                        paramter.IsJson = true;
+                    }
+                    if (columnInfo.IsArray)
+                    {
+                        paramter.IsArray = true;
+                    }
+                    Parameters.Add(paramter);
+                    return parameterName;
+                }
+                else if (type == UtilConstants.ByteArrayType)
+                {
+                    string bytesString = "0x" + BitConverter.ToString((byte[])value);
+                    return bytesString;
+                }
+                else if (type.IsEnum())
+                {
+                    if (Context.CurrentConnectionConfig.MoreSettings?.TableEnumIsString == true)
+                    {
+                        return value.ToSqlValue();
+                    }
+                    else
+                    {
+                        return Convert.ToInt64(value);
+                    }
+                }
+                else if (type == UtilConstants.DateTimeOffsetType)
+                {
+                    return FormatDateTimeOffset(value);
+                }
+                else if (type == UtilConstants.BoolType)
+                {
+                    return value.ObjToBool() ? "1" : "0";
+                }
+                else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
+                {
+                    return "'" + value.ToString().ToSqlFilter() + "'";
+                }
+                else
+                {
+                    return "'" + value.ToString() + "'";
+                }
+            }
+        }
+
+        public override string FormatDateTimeOffset(object value)
+        {
+            return "'" + ((DateTimeOffset)value).ToString("o") + "'";
+        }
+    }
+}

+ 129 - 0
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineQueryBuilder.cs

@@ -0,0 +1,129 @@
+using SqlSugar;
+using SqlSugar.TDengine;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+{
+    public partial class TDengineQueryBuilder : QueryBuilder
+    {
+        #region Sql Template
+
+        public override string PageTempalte
+        {
+            get
+            {
+                /*
+                 SELECT * FROM TABLE WHERE CONDITION ORDER BY ID DESC LIMIT 10 offset 0
+                 */
+                var template = "SELECT {0} FROM {1} {2} {3} {4} LIMIT {6} offset {5}";
+                return template;
+            }
+        }
+
+        public override string DefaultOrderByTemplate
+        {
+            get
+            {
+                return "ORDER BY NOW() ";
+            }
+        }
+
+        #endregion Sql Template
+
+        #region Common Methods
+
+        public override string GetTableNameString
+        {
+            get
+            {
+                if (TableShortName != null && Context.CurrentConnectionConfig?.MoreSettings?.PgSqlIsAutoToLower == false)
+                {
+                    TableShortName = Builder.GetTranslationColumnName(TableShortName);
+                }
+                return base.GetTableNameString;
+            }
+        }
+
+        public override bool IsComplexModel(string sql)
+        {
+            return Regex.IsMatch(sql, @"AS ""\w+\.\w+""") || Regex.IsMatch(sql, @"AS ""\w+\.\w+\.\w+""");
+        }
+
+        public override string ToSqlString()
+        {
+            base.AppendFilter();
+            string oldOrderValue = OrderByValue;
+            string result = null;
+            sql = new StringBuilder();
+            sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, Skip != null || Take != null ? null : GetOrderByString);
+            if (IsCount) { return sql.ToString(); }
+            if (Skip != null && Take == null)
+            {
+                if (OrderByValue == "ORDER BY ") OrderByValue += GetSelectValue.Split(',')[0];
+                result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, Skip != null || Take != null ? null : GetOrderByString, Skip.ObjToInt(), long.MaxValue);
+            }
+            else if (Skip == null && Take != null)
+            {
+                if (OrderByValue == "ORDER BY ") OrderByValue += GetSelectValue.Split(',')[0];
+                result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 0, Take.ObjToInt());
+            }
+            else if (Skip != null && Take != null)
+            {
+                if (OrderByValue == "ORDER BY ") OrderByValue += GetSelectValue.Split(',')[0];
+                result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() : 0, Take);
+            }
+            else
+            {
+                result = sql.ToString();
+            }
+            OrderByValue = oldOrderValue;
+            result = GetSqlQuerySql(result);
+            if (result.IndexOf("-- No table") > 0)
+            {
+                return "-- No table";
+            }
+            if (TranLock != null)
+            {
+                result = result + TranLock;
+            }
+            return result;
+        }
+
+        #endregion Common Methods
+
+        #region Get SQL Partial
+
+        public override string GetSelectValue
+        {
+            get
+            {
+                string result = string.Empty;
+                if (SelectValue == null || SelectValue is string)
+                {
+                    result = GetSelectValueByString();
+                }
+                else
+                {
+                    result = GetSelectValueByExpression();
+                }
+                if (SelectType == ResolveExpressType.SelectMultiple)
+                {
+                    SelectCacheKey = SelectCacheKey + string.Join("-", JoinQueryInfos.Select(it => it.TableName));
+                }
+                if (IsDistinct)
+                {
+                    result = "distinct " + result;
+                }
+                if (SubToListParameters != null && SubToListParameters.Any())
+                {
+                    result = SubToListMethod(result);
+                }
+                return result;
+            }
+        }
+
+        #endregion Get SQL Partial
+    }
+}

+ 19 - 0
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineUpdateBuilder.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+{
+    public class TDengineUpdateBuilder : UpdateBuilder
+    {
+        public override string ToSqlString()
+        {
+            throw new NotSupportedException("TDengine库不支持更新操作");
+        }
+
+        protected override string TomultipleSqlString(List<IGrouping<int, DbColumnInfo>> groupList)
+        {
+            throw new NotSupportedException("TDengine库不支持更新操作");
+        }
+    }
+}

+ 127 - 0
SqlSugar.BzTDengineCore/TDengine/TDengineProvider.cs

@@ -0,0 +1,127 @@
+using SqlSugar;
+using SqlSugar.BzTDengineCore.Tools;
+using SqlSugar.TDengine;
+using SqlSugar.TDengineAdo;
+using System;
+using System.Data;
+using System.Data.Common;
+
+namespace SqlSugar.BzTDengineCore.TDengine
+{
+    public partial class TDengineProvider : AdoProvider
+    {
+        public TDengineProvider()
+        {
+        }
+
+        public override IDbConnection Connection
+        {
+            get
+            {
+                if (_DbConnection == null)
+                {
+                    try
+                    {
+                        var TDengineConnectionString = base.Context.CurrentConnectionConfig.ConnectionString;
+                        _DbConnection = new TDengineConnection(TDengineConnectionString);
+                    }
+                    catch (Exception)
+                    {
+                        throw;
+                    }
+                }
+                return _DbConnection;
+            }
+            set
+            {
+                _DbConnection = value;
+            }
+        }
+
+        public override void BeginTran()
+        {
+        }
+
+        public override void BeginTran(string transactionName)
+        {
+        }
+
+        /// <summary>
+        /// Only SqlServer
+        /// </summary>
+        /// <param name="iso"></param>
+        /// <param name="transactionName"></param>
+        public override void BeginTran(IsolationLevel iso, string transactionName)
+        {
+        }
+
+        public override IDataAdapter GetAdapter()
+        {
+            return new TDengineCore.TDengineDataAdapter();
+        }
+
+        public override DbCommand GetCommand(string sql, SugarParameter[] parameters)
+        {
+            TDengineCommand sqlCommand = new TDengineCommand(sql, (TDengineConnection)Connection);
+            sqlCommand.CommandType = CommandType;
+            sqlCommand.CommandTimeout = CommandTimeOut;
+            //if (this.Transaction != null)
+            //{
+            //    sqlCommand.Transaction = (TDengineTransaction)this.Transaction;
+            //}
+            if (parameters.HasValue())
+            {
+                IDataParameter[] ipars = ToIDbDataParameter(parameters);
+                sqlCommand.Parameters.AddRange((TDengineParameter[])ipars);
+            }
+            CheckConnection();
+            return sqlCommand;
+        }
+
+        public override void SetCommandToAdapter(IDataAdapter dataAdapter, DbCommand command)
+        {
+            ((TDengineCore.TDengineDataAdapter)dataAdapter).SelectCommand = (TDengineCommand)command;
+        }
+
+        public static bool _IsIsNanosecond { get; set; }
+        public static bool _IsMicrosecond { get; set; }
+
+        /// <summary>
+        /// if mysql return MySqlParameter[] pars
+        /// if sqlerver return SqlParameter[] pars ...
+        /// </summary>
+        /// <param name="parameters"></param>
+        /// <returns></returns>
+        public override IDataParameter[] ToIDbDataParameter(params SugarParameter[] parameters)
+        {
+            if (parameters == null || parameters.Length == 0) return null;
+            TDengineParameter[] result = new TDengineParameter[parameters.Length];
+            int i = 0;
+            foreach (var parameter in parameters)
+            {
+                if (parameter.Value == null) parameter.Value = DBNull.Value;
+                if (parameter.Value is bool)
+                {
+                    parameter.Value = parameter.Value?.ToString()?.ToLower();
+                }
+                var sqlParameter = new TDengineParameter(parameter.ParameterName, parameter.Value, parameter.DbType, 0);
+                if (parameter.CustomDbType?.Equals(System.Data.DbType.DateTime2) == true || parameter.Value is DateTime && _IsMicrosecond)
+                {
+                    sqlParameter.IsMicrosecond = true;
+                }
+                else if (parameter.CustomDbType?.Equals(typeof(Date19)) == true || parameter.Value is DateTime && _IsIsNanosecond)
+                {
+                    sqlParameter.IsNanosecond = true;
+                }
+                else if (parameter.Value is DateTime && Context.CurrentConnectionConfig.ConnectionString.Contains("config_"))
+                {
+                    _IsIsNanosecond = sqlParameter.IsNanosecond = Context.CurrentConnectionConfig.ConnectionString.Contains("config_ns");
+                    _IsMicrosecond = sqlParameter.IsMicrosecond = Context.CurrentConnectionConfig.ConnectionString.Contains("config_us");
+                }
+                result[i] = sqlParameter;
+                i++;
+            }
+            return result;
+        }
+    }
+}

+ 155 - 0
SqlSugar.BzTDengineCore/TDengineDataAdapter.cs

@@ -0,0 +1,155 @@
+using SqlSugar.TDengineAdo;
+using System;
+using System.Data.Common;
+using System.Data;
+
+namespace SqlSugar.TDengineCore
+{
+    /// <summary>
+    /// 数据填充器
+    /// </summary>
+    public class TDengineDataAdapter : IDataAdapter
+    {
+        private TDengineCommand command;
+        private string sql;
+        private TDengineConnection _TDengineConnection;
+
+        /// <summary>
+        /// SqlDataAdapter
+        /// </summary>
+        /// <param name="command"></param>
+        public TDengineDataAdapter(TDengineCommand command)
+        {
+            this.command = command;
+        }
+
+        public TDengineDataAdapter()
+        {
+
+        }
+
+        /// <summary>
+        /// SqlDataAdapter
+        /// </summary>
+        /// <param name="sql"></param>
+        /// <param name="_TDengineConnection"></param>
+        public TDengineDataAdapter(string sql, TDengineConnection _TDengineConnection)
+        {
+            this.sql = sql;
+            this._TDengineConnection = _TDengineConnection;
+        }
+
+        /// <summary>
+        /// SelectCommand
+        /// </summary>
+        public TDengineCommand SelectCommand
+        {
+            get
+            {
+                if (this.command == null)
+                {
+                    this.command = new TDengineCommand(this.sql, this._TDengineConnection);
+                }
+                return this.command;
+            }
+            set
+            {
+                this.command = value;
+            }
+        }
+
+        public MissingMappingAction MissingMappingAction { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
+        public MissingSchemaAction MissingSchemaAction { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
+
+        public ITableMappingCollection TableMappings => throw new NotImplementedException();
+
+        /// <summary>
+        /// Fill
+        /// </summary>
+        /// <param name="dt"></param>
+        public void Fill(DataTable dt)
+        {
+            if (dt == null)
+            {
+                dt = new DataTable();
+            }
+            var columns = dt.Columns;
+            var rows = dt.Rows;
+            using (DbDataReader dr = command.ExecuteReader())
+            {
+                for (int i = 0; i < dr.FieldCount; i++)
+                {
+                    string name = dr.GetName(i).Trim();
+                    if (!columns.Contains(name))
+                        columns.Add(new DataColumn(name, dr.GetFieldType(i)));
+                    else
+                    {
+                        columns.Add(new DataColumn(name + i, dr.GetFieldType(i)));
+                    }
+                }
+
+                while (dr.Read())
+                {
+                    DataRow daRow = dt.NewRow();
+                    for (int i = 0; i < columns.Count; i++)
+                    {
+                        daRow[columns[i].ColumnName] = dr.GetValue(i);
+                    }
+                    dt.Rows.Add(daRow);
+                }
+            }
+
+            dt.AcceptChanges();
+        }
+
+        /// <summary>
+        /// Fill
+        /// </summary>
+        /// <param name="ds"></param>
+        public void Fill(DataSet ds)
+        {
+            if (ds == null)
+            {
+                ds = new DataSet();
+            }
+            using (DbDataReader dr = command.ExecuteReader())
+            {
+                do
+                {
+                    var dt = new DataTable();
+                    var columns = dt.Columns;
+                    var rows = dt.Rows;
+                    for (int i = 0; i < dr.FieldCount; i++)
+                    {
+                        string name = dr.GetName(i).Trim();
+                        if (!columns.Contains(name))
+                            columns.Add(new DataColumn(name, dr.GetFieldType(i)));
+                        else
+                        {
+                            columns.Add(new DataColumn(name + i, dr.GetFieldType(i)));
+                        }
+
+                    }
+
+                    while (dr.Read())
+                    {
+                        DataRow daRow = dt.NewRow();
+                        for (int i = 0; i < columns.Count; i++)
+                        {
+                            daRow[columns[i].ColumnName] = dr.GetValue(i);
+                        }
+                        dt.Rows.Add(daRow);
+                    }
+                    dt.AcceptChanges();
+                    ds.Tables.Add(dt);
+                } while (dr.NextResult());
+            }
+        } 
+
+        public DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType)
+        {
+            throw new NotImplementedException();
+        }
+         
+    }
+}

+ 21 - 0
SqlSugar.BzTDengineCore/Tools/DateTime16.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Data;
+
+namespace SqlSugar.BzTDengineCore.Tools
+{
+    public class DateTime16 : ISugarDataConverter
+    {
+        public SugarParameter ParameterConverter<T>(object columnValue, int columnIndex)
+        {
+            var name = "@Common" + columnIndex;
+            Type undertype = UtilMethods.GetUnderType(typeof(T));//获取没有nullable的枚举类型
+            return new SugarParameter(name, columnValue, undertype) { CustomDbType = System.Data.DbType.DateTime2 };
+        }
+
+        public T QueryConverter<T>(IDataRecord dr, int i)
+        {
+            var value = dr.GetValue(i);
+            return (T)UtilMethods.ChangeType2(value, typeof(T));
+        }
+    }
+}

+ 26 - 0
SqlSugar.BzTDengineCore/Tools/DateTime19.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Data;
+
+namespace SqlSugar.BzTDengineCore.Tools
+{
+    internal enum Date19
+    {
+        time = 19
+    }
+
+    public class DateTime19 : ISugarDataConverter
+    {
+        public SugarParameter ParameterConverter<T>(object columnValue, int columnIndex)
+        {
+            var name = "@Common" + columnIndex;
+            Type undertype = UtilMethods.GetUnderType(typeof(T));//获取没有nullable的枚举类型
+            return new SugarParameter(name, columnValue, undertype) { CustomDbType = typeof(Date19) };
+        }
+
+        public T QueryConverter<T>(IDataRecord dr, int i)
+        {
+            var value = dr.GetValue(i);
+            return (T)UtilMethods.ChangeType2(value, typeof(T));
+        }
+    }
+}

+ 64 - 0
SqlSugar.BzTDengineCore/Tools/ErrorMessage.cs

@@ -0,0 +1,64 @@
+using System.Collections.Generic;
+
+namespace SqlSugar.BzTDengineCore.Tools
+{
+    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<string, string>, or contact the author!!",
+                                       "暂时不支持该类型的Dictionary 你可以试试 Dictionary<string ,string>或者联系作者!!");
+            }
+        }
+
+        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<string> formatArgs = new List<string>() { enMessage, cnMessage };
+                formatArgs.AddRange(args);
+                return string.Format(@"中文提示 : {1}
+English Message : {0}", formatArgs.ToArray());
+            }
+            else if (SugarLanguageType == LanguageType.English)
+            {
+                return enMessage;
+            }
+            else
+            {
+                return cnMessage;
+            }
+        }
+    }
+}

+ 73 - 0
SqlSugar.BzTDengineCore/Tools/FileHelper.cs

@@ -0,0 +1,73 @@
+using System;
+using System.IO;
+using System.Text;
+
+namespace SqlSugar.BzTDengineCore.Tools
+{
+    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);
+
+                    //Create File
+                    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)
+        {
+            return File.Exists(filePath);
+        }
+    }
+}

+ 70 - 0
SqlSugar.BzTDengineCore/Tools/UtilConstants.cs

@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Dynamic;
+
+namespace SqlSugar.BzTDengineCore.Tools
+{
+    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<int, int>);
+        internal static Type DicIS = typeof(KeyValuePair<int, string>);
+        internal static Type DicSi = typeof(KeyValuePair<string, int>);
+        internal static Type DicSS = typeof(KeyValuePair<string, string>);
+        internal static Type DicOO = typeof(KeyValuePair<object, object>);
+        internal static Type DicSo = typeof(KeyValuePair<string, object>);
+        internal static Type DicArraySS = typeof(Dictionary<string, string>);
+        internal static Type DicArraySO = typeof(Dictionary<string, object>);
+
+        public static Type SugarType = typeof(SqlSugarProvider);
+
+        internal static Type[] NumericalTypes = new Type[]
+        {
+            typeof(int),
+            typeof(uint),
+            typeof(byte),
+            typeof(sbyte),
+            typeof(long),
+            typeof(ulong),
+            typeof(short),
+            typeof(ushort),
+        };
+
+        internal static string[] DateTypeStringList = new string[]
+        {
+                "Year",
+                "Month",
+                "Day",
+                "Hour",
+                "Second" ,
+                "Minute",
+                "Millisecond",
+                "Date"
+        };
+    }
+}

+ 136 - 0
SqlSugar.BzTDengineCore/Tools/UtilExtensions.cs

@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+namespace SqlSugar.TDengine
+{
+    /// <summary>
+    ///Common Extensions for external users
+    /// </summary>
+    public static class UtilExtensions
+    {
+        public static string ObjToStringNoTrim(this object thisValue)
+        {
+            if (thisValue != null) return thisValue.ToString();
+            return "";
+        }
+        public static string ToLower(this string value, bool isLower) 
+        {
+            if (isLower) 
+            {
+                return value.ObjToString().ToLower();
+            }
+            return value.ObjToString();
+        }
+        public static int ObjToInt(this object thisValue)
+        {
+            int reval = 0;
+            if (thisValue == null) return 0;
+            if (thisValue is Enum)
+            {
+                return (int)thisValue;
+            }
+            if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return reval;
+        }
+
+        public static int ObjToInt(this object thisValue, int errorValue)
+        {
+            int reval = 0;
+            if (thisValue is Enum)
+            {
+                return (int)thisValue;
+            }
+            if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return errorValue;
+        }
+
+        public static double ObjToMoney(this object thisValue)
+        {
+            double reval = 0;
+            if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return 0;
+        }
+
+        public static double ObjToMoney(this object thisValue, double errorValue)
+        {
+            double reval = 0;
+            if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return errorValue;
+        }
+
+        public static string ObjToString(this object thisValue)
+        {
+            if (thisValue != null) return thisValue.ToString().Trim();
+            return "";
+        }
+
+        public static string ObjToString(this object thisValue, string errorValue)
+        {
+            if (thisValue != null) return thisValue.ToString().Trim();
+            return errorValue;
+        }
+
+        public static Decimal ObjToDecimal(this object thisValue)
+        {
+            Decimal reval = 0;
+            if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return 0;
+        }
+
+        public static Decimal ObjToDecimal(this object thisValue, decimal errorValue)
+        {
+            Decimal reval = 0;
+            if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return errorValue;
+        }
+
+        public static DateTime ObjToDate(this object thisValue)
+        {
+            DateTime reval = DateTime.MinValue;
+            if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
+            {
+                reval = Convert.ToDateTime(thisValue);
+            }
+            return reval;
+        }
+
+        public static DateTime ObjToDate(this object thisValue, DateTime errorValue)
+        {
+            DateTime reval = DateTime.MinValue;
+            if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return errorValue;
+        }
+
+        public static bool ObjToBool(this object thisValue)
+        {
+            bool reval = false;
+            if (thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out reval))
+            {
+                return reval;
+            }
+            return reval;
+        }
+    }
+}

+ 521 - 0
SqlSugar.BzTDengineCore/Tools/UtilMethods.cs

@@ -0,0 +1,521 @@
+using SqlSugar.BzTDengineCore.Tools;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Globalization;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Security.Cryptography;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace SqlSugar.TDengine
+{
+    public class UtilMethods
+    {
+        public static long ToUnixTimestamp(DateTime dateTime)
+        {
+            // If the DateTime is Utc, use ToUnixTimeMilliseconds directly
+            if (dateTime.Kind == DateTimeKind.Utc)
+            {
+                return new DateTimeOffset(dateTime).ToUnixTimeMilliseconds();
+            }
+            else
+            {
+                // Convert local DateTime to Utc before converting to Unix timestamp
+                return new DateTimeOffset(dateTime.ToUniversalTime()).ToUnixTimeMilliseconds();
+            }
+        }
+        internal static DateTime GetMinDate(ConnectionConfig currentConnectionConfig)
+        {
+            if (currentConnectionConfig.MoreSettings == null)
+            {
+                return Convert.ToDateTime("1900-01-01");
+            }
+            else if (currentConnectionConfig.MoreSettings.DbMinDate == null)
+            {
+                return Convert.ToDateTime("1900-01-01");
+            }
+            else
+            {
+                return currentConnectionConfig.MoreSettings.DbMinDate.Value;
+            }
+        }
+        internal static DateTime ConvertFromDateTimeOffset(DateTimeOffset dateTime)
+        {
+            if (dateTime.Offset.Equals(TimeSpan.Zero))
+                return dateTime.UtcDateTime;
+            else if (dateTime.Offset.Equals(TimeZoneInfo.Local.GetUtcOffset(dateTime.DateTime)))
+                return DateTime.SpecifyKind(dateTime.DateTime, DateTimeKind.Local);
+            else
+                return dateTime.DateTime;
+        }
+
+        internal static object To(object value, Type destinationType)
+        {
+            return To(value, destinationType, CultureInfo.InvariantCulture);
+        }
+
+        internal static object To(object value, Type destinationType, CultureInfo culture)
+        {
+            if (value != null)
+            {
+                destinationType = UtilMethods.GetUnderType(destinationType);
+                var sourceType = value.GetType();
+
+                var destinationConverter = TypeDescriptor.GetConverter(destinationType);
+                if (destinationConverter != null && destinationConverter.CanConvertFrom(value.GetType()))
+                    return destinationConverter.ConvertFrom(null, culture, value);
+
+                var sourceConverter = TypeDescriptor.GetConverter(sourceType);
+                if (sourceConverter != null && sourceConverter.CanConvertTo(destinationType))
+                    return sourceConverter.ConvertTo(null, culture, value, destinationType);
+
+                if (destinationType.IsEnum && value is int)
+                    return Enum.ToObject(destinationType, (int)value);
+
+                if (!destinationType.IsInstanceOfType(value))
+                    return Convert.ChangeType(value, destinationType, culture);
+            }
+            return value;
+        }
+        public static bool IsAnyAsyncMethod(StackFrame[] methods)
+        {
+            bool isAsync = false;
+            foreach (var item in methods)
+            {
+                if (UtilMethods.IsAsyncMethod(item.GetMethod()))
+                {
+                    isAsync = true;
+                    break;
+                }
+            }
+            return isAsync;
+        }
+
+        public static bool IsAsyncMethod(MethodBase method)
+        {
+            if (method == null)
+            {
+                return false;
+            }
+            if (method.DeclaringType != null)
+            {
+                if (method.DeclaringType.GetInterfaces().Contains(typeof(IAsyncStateMachine)))
+                {
+                    return true;
+                }
+            }
+            var name = method.Name;
+            if (name.Contains("OutputAsyncCausalityEvents"))
+            {
+                return true;
+            }
+            if (name.Contains("OutputWaitEtwEvents"))
+            {
+                return true;
+            }
+            if (name.Contains("ExecuteAsync"))
+            {
+                return true;
+            }
+            Type attType = typeof(AsyncStateMachineAttribute);
+            var attrib = (AsyncStateMachineAttribute)method.GetCustomAttribute(attType);
+            return (attrib != null);
+        }
+
+        public static StackTraceInfo GetStackTrace()
+        {
+
+            StackTrace st = new StackTrace(true);
+            StackTraceInfo info = new StackTraceInfo();
+            info.MyStackTraceList = new List<StackTraceInfoItem>();
+            info.SugarStackTraceList = new List<StackTraceInfoItem>();
+            for (int i = 0; i < st.FrameCount; i++)
+            {
+                var frame = st.GetFrame(i);
+                if (frame.GetMethod().Module.Name.ToLower() != "sqlsugar.dll" && frame.GetMethod().Name.First() != '<')
+                {
+                    info.MyStackTraceList.Add(new StackTraceInfoItem()
+                    {
+                        FileName = frame.GetFileName(),
+                        MethodName = frame.GetMethod().Name,
+                        Line = frame.GetFileLineNumber()
+                    });
+                }
+                else
+                {
+                    info.SugarStackTraceList.Add(new StackTraceInfoItem()
+                    {
+                        FileName = frame.GetFileName(),
+                        MethodName = frame.GetMethod().Name,
+                        Line = frame.GetFileLineNumber()
+                    });
+                }
+            }
+            return info;
+        }
+
+        internal static T To<T>(object value)
+        {
+            return (T)To(value, typeof(T));
+        }
+        internal static Type GetUnderType(Type oldType)
+        {
+            Type type = Nullable.GetUnderlyingType(oldType);
+            return type == null ? oldType : type;
+        }
+        public static string ReplaceSqlParameter(string itemSql, SugarParameter itemParameter, string newName)
+        {
+            itemSql = Regex.Replace(itemSql, string.Format(@"{0} ", "\\" + itemParameter.ParameterName), newName + " ", RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@"{0}\)", "\\" + itemParameter.ParameterName), newName + ")", RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@"{0}\,", "\\" + itemParameter.ParameterName), newName + ",", RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@"{0}$", "\\" + itemParameter.ParameterName), newName, RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@"\+{0}\+", "\\" + itemParameter.ParameterName), "+" + newName + "+", RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@"\+{0} ", "\\" + itemParameter.ParameterName), "+" + newName + " ", RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@" {0}\+", "\\" + itemParameter.ParameterName), " " + newName + "+", RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@"\|\|{0}\|\|", "\\" + itemParameter.ParameterName), "||" + newName + "||", RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@"\={0}\+", "\\" + itemParameter.ParameterName), "=" + newName + "+", RegexOptions.IgnoreCase);
+            itemSql = Regex.Replace(itemSql, string.Format(@"{0}\|\|", "\\" + itemParameter.ParameterName), newName + "||", RegexOptions.IgnoreCase);
+            return itemSql;
+        }
+        internal static Type GetRootBaseType(Type entityType)
+        {
+            var baseType = entityType.BaseType;
+            while (baseType != null && baseType.BaseType != UtilConstants.ObjType)
+            {
+                baseType = baseType.BaseType;
+            }
+            return baseType;
+        }
+
+
+        internal static Type GetUnderType(PropertyInfo propertyInfo, ref bool isNullable)
+        {
+            Type unType = Nullable.GetUnderlyingType(propertyInfo.PropertyType);
+            isNullable = unType != null;
+            unType = unType ?? propertyInfo.PropertyType;
+            return unType;
+        }
+
+        internal static Type GetUnderType(PropertyInfo propertyInfo)
+        {
+            Type unType = Nullable.GetUnderlyingType(propertyInfo.PropertyType);
+            unType = unType ?? propertyInfo.PropertyType;
+            return unType;
+        }
+
+        internal static bool IsNullable(PropertyInfo propertyInfo)
+        {
+            Type unType = Nullable.GetUnderlyingType(propertyInfo.PropertyType);
+            return unType != null;
+        }
+
+        internal static bool IsNullable(Type type)
+        {
+            Type unType = Nullable.GetUnderlyingType(type);
+            return unType != null;
+        }
+        //internal static T IsNullReturnNew<T>(T returnObj) where T : new()
+        //{
+        //    if (returnObj.IsNullOrEmpty())
+        //    {
+        //        returnObj = new T();
+        //    }
+        //    return returnObj;
+        //}
+        public static object ChangeType2(object value, Type type)
+        {
+            if (value == null && type.IsGenericType) return Activator.CreateInstance(type);
+            if (value == null) return null;
+            if (type == value.GetType()) return value;
+            if (type.IsEnum)
+            {
+                if (value is string)
+                    return Enum.Parse(type, value as string);
+                else
+                    return Enum.ToObject(type, value);
+            }
+            if (!type.IsInterface && type.IsGenericType)
+            {
+                Type innerType = type.GetGenericArguments()[0];
+                object innerValue = ChangeType(value, innerType);
+                return Activator.CreateInstance(type, new object[] { innerValue });
+            }
+            if (value is string && type == typeof(Guid)) return new Guid(value as string);
+            if (value is string && type == typeof(Version)) return new Version(value as string);
+            if (!(value is IConvertible)) return value;
+            return Convert.ChangeType(value, type);
+        }
+
+        internal static T ChangeType<T>(T obj, Type type)
+        {
+            return (T)Convert.ChangeType(obj, type);
+        }
+
+        internal static T ChangeType<T>(T obj)
+        {
+            return (T)Convert.ChangeType(obj, typeof(T));
+        }
+
+        internal static DateTimeOffset GetDateTimeOffsetByDateTime(DateTime date)
+        {
+            date = DateTime.SpecifyKind(date, DateTimeKind.Utc);
+            DateTimeOffset utcTime2 = date;
+            return utcTime2;
+        }
+
+        //internal static void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex, string append = null)
+        //{
+        //    if (appendSql.HasValue() && parameters.HasValue())
+        //    {
+        //        foreach (var parameter in parameters.OrderByDescending(it => it.ParameterName.Length))
+        //        {
+        //            //Compatible with.NET CORE parameters case
+        //            var name = parameter.ParameterName;
+        //            string newName = name + append + addIndex;
+        //            appendSql = ReplaceSqlParameter(appendSql, parameter, newName);
+        //            parameter.ParameterName = newName;
+        //        }
+        //    }
+        //}
+
+        internal static string GetPackTable(string sql, string shortName)
+        {
+            return string.Format(" ({0}) {1} ", sql, shortName);
+        }
+
+        public static Func<string, object> GetTypeConvert(object value)
+        {
+            if (value is int || value is uint || value is int? || value is uint?)
+            {
+                return x => Convert.ToInt32(x);
+            }
+            else if (value is short || value is ushort || value is short? || value is ushort?)
+            {
+                return x => Convert.ToInt16(x);
+            }
+            else if (value is long || value is long? || value is ulong? || value is long?)
+            {
+                return x => Convert.ToInt64(x);
+            }
+            else if (value is DateTime|| value is DateTime?)
+            {
+                return x => Convert.ToDateTime(x);
+            }
+            else if (value is bool||value is bool?)
+            {
+                return x => Convert.ToBoolean(x);
+            }
+            return null;
+        }
+
+        internal static string GetTypeName(object value)
+        {
+            if (value == null)
+            {
+                return null;
+            }
+            else 
+            {
+                return value.GetType().Name;
+            }
+        }
+
+        internal static string GetParenthesesValue(string dbTypeName)
+        {
+            if (Regex.IsMatch(dbTypeName, @"\(.+\)"))
+            {
+                dbTypeName = Regex.Replace(dbTypeName, @"\(.+\)", "");
+            }
+            dbTypeName = dbTypeName.Trim();
+            return dbTypeName;
+        }
+
+        internal static T GetOldValue<T>(T value, Action action)
+        {
+            action();
+            return value;
+        }
+
+        internal static object DefaultForType(Type targetType)
+        {
+            return targetType.IsValueType ? Activator.CreateInstance(targetType) : null;
+        }
+
+        internal static Int64 GetLong(byte[] bytes)
+        {
+            return Convert.ToInt64(string.Join("", bytes).PadRight(20, '0'));
+        }
+        public static object GetPropertyValue<T>(T t, string PropertyName)
+        {
+            return t.GetType().GetProperty(PropertyName).GetValue(t, null);
+        }
+        internal static string GetMD5(string myString)
+        {
+            MD5 md5 = new MD5CryptoServiceProvider();
+            byte[] fromData = System.Text.Encoding.Unicode.GetBytes(myString);
+            byte[] targetData = md5.ComputeHash(fromData);
+            string byte2String = null;
+
+            for (int i = 0; i < targetData.Length; i++)
+            {
+                byte2String += targetData[i].ToString("x");
+            }
+
+            return byte2String;
+        }
+
+        //public static string EncodeBase64(string code)
+        //{
+        //    if (code.IsNullOrEmpty()) return code;
+        //    string encode = "";
+        //    byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(code);
+        //    try
+        //    {
+        //        encode = Convert.ToBase64String(bytes);
+        //    }
+        //    catch
+        //    {
+        //        encode = code;
+        //    }
+        //    return encode;
+        //}
+        public static string ConvertNumbersToString(string value)
+        {
+            string[] splitInt = value.Split(new char[] { '9' }, StringSplitOptions.RemoveEmptyEntries);
+
+            var splitChars = splitInt.Select(s => Convert.ToChar(
+                                              Convert.ToInt32(s, 8)
+                                            ).ToString());
+
+            return string.Join("", splitChars);
+        }
+        public static string ConvertStringToNumbers(string value)
+        {
+            StringBuilder sb = new StringBuilder();
+
+            foreach (char c in value)
+            {
+                int cAscil = (int)c;
+                sb.Append(Convert.ToString(c, 8) + "9");
+            }
+
+            return sb.ToString();
+        }
+
+        //public static string DecodeBase64(string code)
+        //{
+        //    try
+        //    {
+        //        if (code.IsNullOrEmpty()) return code;
+        //        string decode = "";
+        //        byte[] bytes = Convert.FromBase64String(code);
+        //        try
+        //        {
+        //            decode = Encoding.GetEncoding("utf-8").GetString(bytes);
+        //        }
+        //        catch
+        //        {
+        //            decode = code;
+        //        }
+        //        return decode;
+        //    }
+        //    catch
+        //    {
+        //        return code;
+        //    }
+        //}
+
+        public static void DataInoveByExpresson<Type>(Type[] datas, MethodCallExpression callExpresion)
+        {
+            var methodInfo = callExpresion.Method;
+            foreach (var item in datas)
+            {
+                if (callExpresion.Arguments.Count == 0)
+                {
+                    methodInfo.Invoke(item, null);
+                }
+                else
+                {
+                    List<object> methodParameters = new List<object>();
+                    foreach (var callItem in callExpresion.Arguments)
+                    {
+                        var parameter = callItem.GetType().GetProperties().FirstOrDefault(it => it.Name == "Value");
+                        if (parameter == null)
+                        {
+                            var value = LambdaExpression.Lambda(callItem).Compile().DynamicInvoke();
+                            methodParameters.Add(value);
+                        }
+                        else
+                        {
+                            var value = parameter.GetValue(callItem, null);
+                            methodParameters.Add(value);
+                        }
+                    }
+                    methodInfo.Invoke(item, methodParameters.ToArray());
+                }
+            }
+        }
+
+        public static Dictionary<string, T> EnumToDictionary<T>()
+        {
+            Dictionary<string, T> dic = new Dictionary<string, T>();
+            if (!typeof(T).IsEnum)
+            {
+                return dic;
+            }
+            string desc = string.Empty;
+            foreach (var item in Enum.GetValues(typeof(T)))
+            {
+                var key = item.ToString().ToLower();
+                if (!dic.ContainsKey(key))
+                    dic.Add(key, (T)item);
+            }
+            return dic;
+        }
+        //public static object ConvertDataByTypeName(string ctypename,string value)
+        //{
+        //    var item = new ConditionalModel() {
+        //        CSharpTypeName = ctypename,
+        //        FieldValue = value
+        //    };
+        //    if (item.CSharpTypeName.EqualCase(UtilConstants.DecType.Name))
+        //    {
+        //        return Convert.ToDecimal(item.FieldValue);
+        //    }
+        //    else if (item.CSharpTypeName.EqualCase(UtilConstants.DobType.Name))
+        //    {
+        //        return Convert.ToDouble(item.FieldValue);
+        //    }
+        //    else if (item.CSharpTypeName.EqualCase(UtilConstants.DateType.Name))
+        //    {
+        //        return Convert.ToDateTime(item.FieldValue);
+        //    }
+        //    else if (item.CSharpTypeName.EqualCase(UtilConstants.IntType.Name))
+        //    {
+        //        return Convert.ToInt32(item.FieldValue);
+        //    }
+        //    else if (item.CSharpTypeName.EqualCase(UtilConstants.LongType.Name))
+        //    {
+        //        return Convert.ToInt64(item.FieldValue);
+        //    }
+        //    else if (item.CSharpTypeName.EqualCase(UtilConstants.ShortType.Name))
+        //    {
+        //        return Convert.ToInt16(item.FieldValue);
+        //    }
+        //    else if (item.CSharpTypeName.EqualCase(UtilConstants.DateTimeOffsetType.Name))
+        //    {
+        //        return UtilMethods.GetDateTimeOffsetByDateTime(Convert.ToDateTime(item.FieldValue));
+        //    }
+        //    else
+        //    {
+        //        return item.FieldValue;
+        //    }
+        //}
+    }
+}

+ 173 - 0
SqlSugar.BzTDengineCore/Tools/ValidateExtensions.cs

@@ -0,0 +1,173 @@
+using SqlSugar.BzTDengineCore.Tools;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+namespace SqlSugar.TDengine
+{
+    internal static class ValidateExtensions
+    {
+        public static bool IsInRange(this int thisValue, int begin, int end)
+        {
+            return thisValue >= begin && thisValue <= end;
+        }
+
+        public static bool IsInRange(this DateTime thisValue, DateTime begin, DateTime end)
+        {
+            return thisValue >= begin && thisValue <= end;
+        }
+
+        public static bool IsIn<T>(this T thisValue, params T[] values)
+        {
+            return values.Contains(thisValue);
+        }
+
+        public static bool IsContainsIn(this string thisValue, params string[] inValues)
+        {
+            return inValues.Any(it => thisValue.Contains(it));
+        }
+
+        public static bool IsNullOrEmpty(this object thisValue)
+        {
+            if (thisValue == null || thisValue == DBNull.Value) return true;
+            return thisValue.ToString() == "";
+        }
+
+        public static bool IsNullOrEmpty(this Guid? thisValue)
+        {
+            if (thisValue == null) return true;
+            return thisValue == Guid.Empty;
+        }
+  
+        public static bool IsNullOrEmpty(this Guid thisValue)
+        {
+            if (thisValue == null) return true;
+            return thisValue == Guid.Empty;
+        }
+
+        public static bool IsNullOrEmpty(this IEnumerable<object> thisValue)
+        {
+            if (thisValue == null || thisValue.Count() == 0) return true;
+            return false;
+        }
+
+        public static bool HasValue(this object thisValue)
+        {
+            if (thisValue == null || thisValue == DBNull.Value) return false;
+            return thisValue.ToString() != "";
+        }
+
+        public static bool HasValue(this IEnumerable<object> thisValue)
+        {
+            if (thisValue == null || thisValue.Count() == 0) return false;
+            return true;
+        }
+
+        public static bool IsValuable(this IEnumerable<KeyValuePair<string,string>> thisValue)
+        {
+            if (thisValue == null || thisValue.Count() == 0) return false;
+            return true;
+        }
+
+        public static bool IsZero(this object thisValue)
+        {
+            return (thisValue == null || thisValue.ToString() == "0");
+        }
+
+        public static bool IsInt(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            return Regex.IsMatch(thisValue.ToString(), @"^\d+$");
+        }
+
+        /// <returns></returns>
+        public static bool IsNoInt(this object thisValue)
+        {
+            if (thisValue == null) return true;
+            return !Regex.IsMatch(thisValue.ToString(), @"^\d+$");
+        }
+
+        public static bool IsMoney(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            double outValue = 0;
+            return double.TryParse(thisValue.ToString(), out outValue);
+        }
+        public static bool IsGuid(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            Guid outValue = Guid.Empty;
+            return Guid.TryParse(thisValue.ToString(), out outValue);
+        }
+
+        public static bool IsDate(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            DateTime outValue = DateTime.MinValue;
+            return DateTime.TryParse(thisValue.ToString(), out outValue);
+        }
+
+        public static bool IsEamil(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            return Regex.IsMatch(thisValue.ToString(), @"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$");
+        }
+
+        public static bool IsMobile(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            return Regex.IsMatch(thisValue.ToString(), @"^\d{11}$");
+        }
+
+        public static bool IsTelephone(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            return System.Text.RegularExpressions.Regex.IsMatch(thisValue.ToString(), @"^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{8}$");
+
+        }
+
+        public static bool IsIDcard(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            return System.Text.RegularExpressions.Regex.IsMatch(thisValue.ToString(), @"^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$");
+        }
+
+        public static bool IsFax(this object thisValue)
+        {
+            if (thisValue == null) return false;
+            return System.Text.RegularExpressions.Regex.IsMatch(thisValue.ToString(), @"^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$");
+        }
+
+        public static bool IsMatch(this object thisValue, string pattern)
+        {
+            if (thisValue == null) return false;
+            Regex reg = new Regex(pattern);
+            return reg.IsMatch(thisValue.ToString());
+        }
+        public static bool IsAnonymousType(this Type type)
+        {
+            string typeName = type.Name;
+            return typeName.Contains("<>") && typeName.Contains("__") && typeName.Contains("AnonymousType");
+        }
+        public static bool IsCollectionsList(this string thisValue)
+        {
+            return (thisValue + "").StartsWith("System.Collections.Generic.List")|| (thisValue + "").StartsWith("System.Collections.Generic.IEnumerable");
+        }
+        public static bool IsStringArray(this string thisValue)
+        {
+            return (thisValue + "").IsMatch(@"System\.[a-z,A-Z,0-9]+?\[\]");
+        }
+        public static bool IsEnumerable(this string thisValue)
+        {
+            return (thisValue + "").StartsWith("System.Linq.Enumerable");
+        }
+
+        public static Type StringType = typeof (string);
+
+        public static bool IsClass(this Type thisValue)
+        {
+            return thisValue != StringType && thisValue.IsEntity()&&thisValue!=UtilConstants.ByteArrayType;
+        }
+    }
+}

+ 1 - 0
SqlSugar.BzTDengineCore/nuget.bat

@@ -0,0 +1 @@
+%~dp0nuget.exe pack %~dp0SqlSugar.OdbcCore.nuspec -OutputDirectory %~dp0

+ 7 - 0
WcsFramework.sln

@@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.Entity.Protocol", "业
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.WorkEngineering", "业务工程\分拣库\WCS.WorkEngineering\WCS.WorkEngineering.csproj", "{0AF64876-D5EA-426F-A349-0BF7593067EF}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlSugar.BzTDengineCore", "SqlSugar.BzTDengineCore\SqlSugar.BzTDengineCore.csproj", "{38A8241F-E038-449B-9B47-E3AB4B02DC10}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -79,6 +81,10 @@ Global
 		{0AF64876-D5EA-426F-A349-0BF7593067EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{0AF64876-D5EA-426F-A349-0BF7593067EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{0AF64876-D5EA-426F-A349-0BF7593067EF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{38A8241F-E038-449B-9B47-E3AB4B02DC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{38A8241F-E038-449B-9B47-E3AB4B02DC10}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{38A8241F-E038-449B-9B47-E3AB4B02DC10}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{38A8241F-E038-449B-9B47-E3AB4B02DC10}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -96,6 +102,7 @@ Global
 		{CD308645-A4F6-4AC4-891B-B7AE0547EA08} = {5C319C8D-9EC2-4C1E-9924-437DB3239AE1}
 		{98372FF1-0B5C-4FC1-A34A-44306F9DBD13} = {D5DB0F10-73EE-4B54-A00E-2E6A33229B95}
 		{0AF64876-D5EA-426F-A349-0BF7593067EF} = {D5DB0F10-73EE-4B54-A00E-2E6A33229B95}
+		{38A8241F-E038-449B-9B47-E3AB4B02DC10} = {C783651F-7EB6-40BA-8E68-525F93B8FCED}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {2C009DED-1CDE-4D15-A895-5013ED32E8FC}