IoTSharp.ORM.Taos
3.0.21.74
See the version list below for details.
dotnet add package IoTSharp.ORM.Taos --version 3.0.21.74
NuGet\Install-Package IoTSharp.ORM.Taos -Version 3.0.21.74
<PackageReference Include="IoTSharp.ORM.Taos" Version="3.0.21.74" />
paket add IoTSharp.ORM.Taos --version 3.0.21.74
#r "nuget: IoTSharp.ORM.Taos, 3.0.21.74"
// Install IoTSharp.ORM.Taos as a Cake Addin #addin nuget:?package=IoTSharp.ORM.Taos&version=3.0.21.74 // Install IoTSharp.ORM.Taos as a Cake Tool #tool nuget:?package=IoTSharp.ORM.Taos&version=3.0.21.74
IoTSharp.EntityFrameworkCore.Taos
项目简介
Entity, Framework, EF, Core, Data, O/RM, entity-framework-core,TDengine
IoTSharp.Data.Taos 是 TDengine的ADO.Net提供程序。 它将允许你通过原生动态库、WebSocket、RESTful 三种协议访问TDengine,通过 Schemaless 完美实现了ExecuteBulkInsert批量插入、Stmt 实现了参数化执行。
协议 | 依赖 | 说明 |
---|---|---|
WebSocket | 无依赖 | 纯C#实现, 支持 Schemaless 和 Stmt参数化 |
Native | libtaos | 原生协议, 支持3.0.x libtaos 动态库,支持 Schemaless 和 Stmt参数化。使用前必须安装 TDengine-client |
RESTful | 无依赖 | 纯C#实现, 不支持 Schemaless 和 Stmt参数化 |
Schemaless
通过 Schemaless 实现的 ExecuteBulkInsert 支持 TSDB_SML_LINE_PROTOCOL 和TSDB_SML_JSON_PROTOCOL 。 透过TSDB_SML_JSON_PROTOCOL也支持了InfluxDB Client中的 RecordData 的数据写法。
RecordData示例
var rec= RecordData.table("meters").Tag("location", "Beijing.Haidian").Tag("groupid", "2").Timestamp(DateTime.Now.ToUniversalTime(), TimePrecision.Ms)
.Field("current", 12.1).Field("voltage", 234.0).Field("phase",0.33);
int result = connection.ExecuteBulkInsert(rec);
IoTSharp.EntityFrameworkCore.Taos 是一个Entity Framework Core 的提供器, 基于IoTSharp.Data.Taos实现。 (原名称为 Maikebing.EntityFrameworkCore.Taos)
NuGet名称 | 版本 | 下载量 | 说明 |
---|---|---|---|
IoTSharp.Data.Taos | ADO.Net Core 基础组件 | ||
IoTSharp.EntityFrameworkCore.Taos | 供EF Core使用的组件 | ||
IoTSharp.HealthChecks.Taos | 供Asp.Net Core 使用的健康检查组件 |
TDengine技术开放日 — 从技术创新和设计思想,认识TDengine
如何使用?
基本示例:
///Specify the name of the database
string database = "db_" + DateTime.Now.ToString("yyyyMMddHHmmss");
string database = "db_" + DateTime.Now.ToString("yyyyMMddHHmmss");
var builder = new TaosConnectionStringBuilder()
{
DataSource = "127.0.0.1",
DataBase = database,
Username = "root",
Password = "kissme",
Port=6060
};
//Example for ADO.Net
using (var connection = new TaosConnection(builder.ConnectionString))
{
connection.Open();
Console.WriteLine("create {0} {1}", database, connection.CreateCommand($"create database {database};").ExecuteNonQuery());
Console.WriteLine("create table t {0} {1}", database, connection.CreateCommand($"create table {database}.t (ts timestamp, cdata int);").ExecuteNonQuery());
Console.WriteLine("insert into t values {0} ", connection.CreateCommand($"insert into {database}.t values ('{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ms")}', 10);").ExecuteNonQuery());
Console.WriteLine("insert into t values {0} ", connection.CreateCommand($"insert into {database}.t values ('{DateTime.Now.AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss.ms")}', 20);").ExecuteNonQuery());
var cmd_select = connection.CreateCommand();
cmd_select.CommandText = $"select * from {database}.t";
var reader = cmd_select.ExecuteReader();
Console.WriteLine(cmd_select.CommandText);
Console.WriteLine("");
ConsoleTableBuilder.From(reader.ToDataTable()).WithFormat(ConsoleTableBuilderFormat.MarkDown).ExportAndWriteLine();
Console.WriteLine("");
Console.WriteLine("DROP TABLE {0} {1}", database, connection.CreateCommand($"DROP TABLE {database}.t;").ExecuteNonQuery());
Console.WriteLine("DROP DATABASE {0} {1}", database, connection.CreateCommand($"DROP DATABASE {database};").ExecuteNonQuery());
connection.Close();
}
//Example for Entity Framework Core
using (var context = new TaosContext(new DbContextOptionsBuilder()
.UseTaos(builder.ConnectionString).Options))
{
Console.WriteLine("EnsureCreated");
context.Database.EnsureCreated();
for (int i = 0; i < 10; i++)
{
var rd = new Random();
context.sensor.Add(new sensor() { ts = DateTime.Now.AddMilliseconds(i), degree = rd.NextDouble(), pm25 = rd.Next(0, 1000) });
}
Console.WriteLine("Saveing");
context.SaveChanges();
Console.WriteLine("");
Console.WriteLine("from s in context.sensor where s.pm25 > 0 select s ");
Console.WriteLine("");
var f = from s in context.sensor where s.pm25 > 0 select s;
var ary = f.ToArray();
ConsoleTableBuilder.From(ary.ToList()).WithFormat(ConsoleTableBuilderFormat.MarkDown).ExportAndWriteLine();
context.Database.EnsureDeleted();
}
Console.WriteLine("");
Console.WriteLine("Pass any key to exit....");
Console.ReadKey();
用于物联网的超级表示例:
IoTSharp/Storage/TaosStorage.cs
using (var connection = new TaosConnection(builder.ConnectionString))
{
connection.Open();
Console.WriteLine("ServerVersion:{0}", connection.ServerVersion);
connection.CreateCommand("DROP DATABASE IF EXISTS IoTSharp").ExecuteNonQuery();
connection.CreateCommand("CREATE DATABASE IoTSharp KEEP 365 DAYS 10 BLOCKS 4;").ExecuteNonQuery();
connection.ChangeDatabase("IoTSharp");
connection.CreateCommand("CREATE TABLE IF NOT EXISTS telemetrydata (ts timestamp,value_type tinyint, value_boolean bool, value_string binary(10240), value_long bigint,value_datetime timestamp,value_double double) TAGS (deviceid binary(32),keyname binary(64));").ExecuteNonQuery();
//connection.CreateCommand($"CREATE TABLE dev_Thermometer USING telemetrydata TAGS (\"Temperature\")").ExecuteNonQuery();
var devid = $"{Guid.NewGuid():N}";
UploadTelemetryData(connection, devid, "Temperature", 999);
UploadTelemetryData(connection,devid, "Humidity", 888);
var devid2 = $"{Guid.NewGuid():N}";
UploadTelemetryData(connection, devid2, "Temperature", 777);
UploadTelemetryData(connection, devid2, "Humidity", 666);
var reader2 = connection.CreateCommand("select last_row(*) from telemetrydata group by deviceid,keyname ;").ExecuteReader();
ConsoleTableBuilder.From(reader2.ToDataTable()).WithFormat(ConsoleTableBuilderFormat.Default).ExportAndWriteLine();
connection.Close();
}
static void UploadTelemetryData( TaosConnection connection, string devid, string keyname, int count)
{
for (int i = 0; i < count; i++)
{
connection.CreateCommand($"INSERT INTO device_{devid}_{keyname} USING telemetrydata TAGS(\"{devid}\",\"{keyname}\") (ts,value_type,value_long) values (now,2,{i});").ExecuteNonQuery();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- IoTSharp.Data.Taos (>= 3.0.21.74)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
IoTSharp.ORM.Taos 访问TDengine数据库的便捷ORM。