Update TDengine

This commit is contained in:
sunkaixuan 2023-08-08 18:14:40 +08:00
parent 9a5f4fe03d
commit 6522c5cb3d
4 changed files with 50 additions and 2 deletions

View File

@ -11,3 +11,9 @@ dotnet_diagnostic.CS8604.severity = none
# CS8600: 将 null 字面量或可能为 null 的值转换为非 null 类型。
dotnet_diagnostic.CS8600.severity = none
# IDE0058: 永远不会使用表达式值
dotnet_diagnostic.IDE0058.severity = silent
# CS8602: 解引用可能出现空引用。
dotnet_diagnostic.CS8602.severity = none

View File

@ -80,9 +80,13 @@ namespace SqlSugar.TDengine
return GetDbColumn(it, null);
}
object value = null;
if (it.Value is DateTime)
if (it?.Value is DateTime)
{
value = ((DateTime)it.Value).ToString("O");
value = it.Value.ObjToDate().ToString("yyyy-MM-dd HH:mm:ss.fff");
}
else if (it?.Value is bool)
{
value = value?.ToString()?.ToLower();
}
else if (it.Value is DateTimeOffset)
{

View File

@ -16,6 +16,19 @@ 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)

View File

@ -57,6 +57,31 @@ namespace OrmTest
voltage = 11
}).ExecuteCommand();
db.Insertable(new List<MyTable02>() {
new MyTable02()
{
ts = DateTime.Now,
current = Convert.ToSingle(1.1),
groupId = 1,
isdelete = true,
name = "haha",
location = "aa",
phase = Convert.ToSingle(1.1),
voltage = 11
},
new MyTable02()
{
ts = DateTime.Now,
current = Convert.ToSingle(1.1),
groupId = 1,
isdelete = true,
name = "haha",
location = "aa",
phase = Convert.ToSingle(1.1),
voltage = 11
}
}).ExecuteCommand();
//查询子表(主表字段也能查出来)
var list = db.Queryable<MyTable02>().ToList();