fixed 修复tag字段支持更多类型

This commit is contained in:
zhulangren
2025-12-21 18:52:31 +08:00
parent 9ac4b1ab5a
commit 260e90df0e
5 changed files with 24 additions and 14 deletions

View File

@@ -11,11 +11,15 @@ namespace SqlSugar.TDengine
if (csharpTypeName == UtilConstants.ByteArrayType.Name)
return "bytea";
if (csharpTypeName.ToLower() == "int32")
csharpTypeName = "int";
csharpTypeName = "int";
if (csharpTypeName.ToLower() == "uint32")
csharpTypeName = "uint";
if (csharpTypeName.ToLower() == "int16")
csharpTypeName = "short";
if (csharpTypeName.ToLower() == "int64")
csharpTypeName = "long";
if (csharpTypeName.ToLower() == "uint64")
csharpTypeName = "ulong";
if (csharpTypeName.ToLower().IsIn("boolean", "bool"))
csharpTypeName = "bool";
if (csharpTypeName == "DateTimeOffset")
@@ -121,16 +125,14 @@ namespace SqlSugar.TDengine
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>("TINYINT",CSharpDataType.@int),
new KeyValuePair<string, CSharpDataType>("TINYINT",CSharpDataType.@sbyte),
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>("TINYINT UNSIGNED",CSharpDataType.@int),
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>("SMALLINT UNSIGNED",CSharpDataType.@ushort),
new KeyValuePair<string, CSharpDataType>("INT UNSIGNED",CSharpDataType.@uint),
new KeyValuePair<string, CSharpDataType>("BIGINT UNSIGNED",CSharpDataType.@ulong),
new KeyValuePair<string, CSharpDataType>("FLOAT",CSharpDataType.Single),
new KeyValuePair<string, CSharpDataType>("DOUBLE",CSharpDataType.@double),
new KeyValuePair<string, CSharpDataType>("float8",CSharpDataType.@double),

View File

@@ -8,6 +8,7 @@ namespace SqlSugar
public enum CSharpDataType
{
@int,
@uint,
@bool,
@string,
@DateTime,
@@ -18,7 +19,9 @@ namespace SqlSugar
@sbyte,
@enum,
@short,
@ushort,
@long,
@ulong,
@object,
@other,
@byteArray,

View File

@@ -16,7 +16,7 @@ namespace TDengineTest
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=test";
public static string ConnectionString = "Host=dikong.chengdan.com;Port=6030;Username=root;Password=taosdata;Database=test";
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号

View File

@@ -32,6 +32,7 @@ namespace TDengineTest
db.Insertable(new CodeFirst0311()
{
Ts = DateTime.Now,
DeviceType = 1,
Boolean = true,
Char = 'a',
Decimal = Convert.ToDecimal(18.2),
@@ -39,16 +40,16 @@ namespace TDengineTest
Int32 = 32,
Int64 = 64,
String = "string",
SByte=3,
SByte = 3,
Byte = 2,
Decimal2 = Convert.ToDecimal(18.3),
Double = Convert.ToDouble(18.44),
Float = Convert.ToSingle(18.45),
String2 = "2",
UInt16=116,
UInt32=332,
UInt64=664
}).ExecuteCommand();
UInt16 = 116,
UInt32 = 332,
UInt64 = 664
}).SetTDengineChildTableName((stableName, it) => $"mytbname_{it.DeviceType}").ExecuteCommand();
var dt = db.Ado.GetDataTable("select * from CodeFirst0311 ");
var list3 = db.Queryable<CodeFirst0311>().ToList();
}

View File

@@ -6,11 +6,15 @@ using System.Text;
namespace TDengineTest
{
[STableAttribute(STableName= "CodeFirst0311", Tag1 =nameof(DeviceType))]
public class CodeFirst0311 : STable
{
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
public DateTime Ts { get; set; }
[SqlSugar.SugarColumn(ColumnDataType = "INT UNSIGNED",IsOnlyIgnoreInsert =true,IsOnlyIgnoreUpdate =true)]
public uint DeviceType { get; set; }
public bool Boolean { get; set; }
public byte Byte { get; set; }
public sbyte SByte { get; set; }