mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
Update TDengine
This commit is contained in:
parent
f761e1bc03
commit
49935d531c
@ -2,6 +2,7 @@
|
|||||||
using SqlSugar.TDengine;
|
using SqlSugar.TDengine;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -11,31 +12,41 @@ namespace TDengineTest
|
|||||||
{
|
{
|
||||||
public static void InsertUsingTag(SqlSugarClient db)
|
public static void InsertUsingTag(SqlSugarClient db)
|
||||||
{
|
{
|
||||||
db.CodeFirst.InitTables<SUsingTagModel>();
|
//创建超级表扔在程序初始话的地方
|
||||||
|
db.CodeFirst.InitTables<SUsingTagModel>();
|
||||||
|
|
||||||
db.Insertable(new List<SUsingTagModel>(){
|
//插入并根据Tag的值创建子表
|
||||||
|
db.CopyNew().Insertable(new List<SUsingTagModel>(){
|
||||||
new SUsingTagModel()
|
new SUsingTagModel()
|
||||||
{
|
{
|
||||||
Boolean = true,
|
Boolean = true,
|
||||||
Tag1 = "a",
|
Tag1 = "a",
|
||||||
Ts = DateTime.Now
|
Ts = DateTime.Now.AddMilliseconds(1)//没启用微秒纳秒时间不能一样
|
||||||
|
|
||||||
},
|
},
|
||||||
new SUsingTagModel()
|
new SUsingTagModel()
|
||||||
{
|
{
|
||||||
Boolean = false,
|
Boolean = false,
|
||||||
Tag1 = "a",
|
Tag1 = "a",
|
||||||
Ts = DateTime.Now
|
Ts = DateTime.Now.AddMilliseconds(2)
|
||||||
|
|
||||||
},
|
},
|
||||||
new SUsingTagModel()
|
new SUsingTagModel()
|
||||||
{
|
{
|
||||||
Boolean = true,
|
Boolean = true,
|
||||||
Tag1 = "b",
|
Tag1 = "b",
|
||||||
Ts = DateTime.Now
|
Ts = DateTime.Now.AddMilliseconds(3)
|
||||||
}})
|
}})
|
||||||
.SetTDengineChildTableName((stableName, it) => $"{stableName}_{it.Tag1}" /*设置子表名字*/ )
|
.SetTDengineChildTableName((stableName, it) => $"{stableName}_{it.Tag1}" /*设置子表名字*/ )
|
||||||
.ExecuteCommand();
|
.ExecuteCommand();
|
||||||
|
|
||||||
|
var list1=db.Queryable<SUsingTagModel>().ToList();
|
||||||
|
|
||||||
|
//查询子表A
|
||||||
|
var tagA = db.Queryable<SUsingTagModel>().Where(it=>it.Tag1=="a").ToList();
|
||||||
|
|
||||||
|
db.Deleteable<SUsingTagModel>().Where(it => it.Ts > Convert.ToDateTime("2020-1-1")).ExecuteCommand();
|
||||||
|
|
||||||
}
|
}
|
||||||
[STableAttribute(STableName = "SUsingTagModel", Tag1 = nameof(Tag1))]
|
[STableAttribute(STableName = "SUsingTagModel", Tag1 = nameof(Tag1))]
|
||||||
public class SUsingTagModel
|
public class SUsingTagModel
|
||||||
@ -43,7 +54,6 @@ namespace TDengineTest
|
|||||||
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
|
||||||
public DateTime Ts { get; set; }
|
public DateTime Ts { get; set; }
|
||||||
public bool Boolean { get; set; }
|
public bool Boolean { get; set; }
|
||||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
|
||||||
public string Tag1 { get; set; }
|
public string Tag1 { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user