diff --git a/docs/en/07-develop/01-connect/_connect_cs.mdx b/docs/en/07-develop/01-connect/_connect_cs.mdx index 77fe2699455d0faa5c0570b882f30a8a8945372b..b81f49b2f0593c65ed6b51b6824d3936f00f2993 100644 --- a/docs/en/07-develop/01-connect/_connect_cs.mdx +++ b/docs/en/07-develop/01-connect/_connect_cs.mdx @@ -2,7 +2,6 @@ {{#include docs/examples/csharp/connect/Program.cs}} ``` -:::info -C# connector supports only native connection for now. - -::: +```csharp title="WebSocket Connection" +{{#include docs/examples/csharp/wsConnect/Program.cs}} +``` diff --git a/docs/en/14-reference/03-connector/09-csharp.mdx b/docs/en/14-reference/03-connector/09-csharp.mdx index c51c542c26b35a27073dcb66185dbd2792b95cda..45bf7fdf82de4293531dc083f6147282358ce03d 100644 --- a/docs/en/14-reference/03-connector/09-csharp.mdx +++ b/docs/en/14-reference/03-connector/09-csharp.mdx @@ -17,7 +17,7 @@ import CSAsyncQuery from "../../07-develop/04-query-data/_cs_async.mdx" `TDengine.Connector` is a C# language connector provided by TDengine that allows C# developers to develop C# applications that access TDengine cluster data. -The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc. The `TDengine.Connector` currently does not provide a REST connection interface. Developers can write their RESTful application by referring to the [REST API](/reference/rest-api/) documentation. +The `TDengine.Connector` connector supports connect to TDengine instances via the TDengine client driver (taosc), providing data writing, querying, subscription, schemaless writing, bind interface, etc.The `TDengine.Connector` also supports WebSocket and developers can build connection through DSN, which supports data writing, querying, and parameter binding, etc. This article describes how to install `TDengine.Connector` in a Linux or Windows environment and connect to TDengine clusters via `TDengine.Connector` to perform basic operations such as data writing and querying. @@ -35,6 +35,10 @@ Please refer to [version support list](/reference/connector#version-support) ## Supported features + + + + 1. Connection Management 2. General Query 3. Continuous Query @@ -42,6 +46,18 @@ Please refer to [version support list](/reference/connector#version-support) 5. Subscription 6. Schemaless + + + + +1. Connection Management +2. General Query +3. Continuous Query +4. Parameter Binding + + + + ## Installation Steps ### Pre-installation preparation @@ -74,11 +90,17 @@ cp -r src/ myProject cd myProject dotnet add exmaple.csproj reference src/TDengine.csproj ``` + ## Establish a Connection + + + + + ``` csharp using TDengineDriver; @@ -112,14 +134,62 @@ namespace TDengineExample ``` + + + + +The structure of the DSN description string is as follows: + +```text +[]://[[:@]:][/][?=[&=]] +|------------|---|-----------|-----------|------|------|------------|-----------------------| +| protocol | | username | password | host | port | database | params | +``` + +The parameters are described as follows: + +* **protocol**: Specify which connection method to use (support http/ws). For example, `ws://localhost:6041` uses Websocket to establish connections. +* **username/password**: Username and password used to create connections. +* **host/port**: Specifies the server and port to establish a connection. Websocket connections default to `localhost:6041`. +* **database**: Specify the default database to connect to. +* **params**:Optional parameters. + +A sample DSN description string is as follows: + +```text +ws://localhost:6041/test +``` + +``` csharp +{{#include docs/examples/csharp/wsConnect/Program.cs}} +``` + + + + ## Usage examples ### Write data #### SQL Write + + + + + + + + +```csharp +{{#include docs/examples/csharp/wsInsert/Program.cs}} +``` + + + + #### InfluxDB line protocol write @@ -132,12 +202,48 @@ namespace TDengineExample +#### Parameter Binding + + + + + +``` csharp +{{#include docs/examples/csharp/stmtInsert/Program.cs}} +``` + + + + + +```csharp +{{#include docs/examples/csharp/wsStmt/Program.cs}} +``` + + + + ### Query data #### Synchronous Query + + + + + + + + +```csharp +{{#include docs/examples/csharp/wsQuery/Program.cs}} +``` + + + + #### Asynchronous query @@ -145,18 +251,21 @@ namespace TDengineExample ### More sample programs |Sample program |Sample program description | -|--------------------------------------------------------------------------------------------------------------------|------------ --------------------------------| +|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------| | [CURD](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/Query/Query.cs) | Table creation, data insertion, and query examples with TDengine.Connector | | [JSON Tag](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/JSONTag) | Writing and querying JSON tag data with TDengine Connector | | [stmt](https://github.com/taosdata/taos-connector-dotnet/tree/3.0/examples/Stmt) | Parameter binding with TDengine Connector | | [schemaless](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/schemaless) | Schemaless writes with TDengine Connector | | [async query](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/AsyncQuery/QueryAsync.cs) | Asynchronous queries with TDengine Connector | -| [TMQ](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | Data subscription with TDengine Connector | +| [Subscription](https://github.com/taosdata/taos-connector-dotnet/blob/3.0/examples/TMQ/TMQ.cs) | Subscription example with TDengine Connector | +| [Basic WebSocket Usage](https://github.com/taosdata/taos-connector-dotnet/blob/5a4a7cd0dbcda114447cdc6d0c6dedd8e84a52da/examples/WS/WebSocketSample.cs) | WebSocket basic data in and out with TDengine connector | +| [WebSocket Parameter Binding](https://github.com/taosdata/taos-connector-dotnet/blob/5a4a7cd0dbcda114447cdc6d0c6dedd8e84a52da/examples/WS/WebSocketSTMT.cs) | WebSocket parameter binding example | ## Important update records | TDengine.Connector | Description | |--------------------|--------------------------------| +| 3.0.1 | Support WebSocket and Cloud,With function query, insert, and parameter binding| | 3.0.0 | Supports TDengine 3.0.0.0. TDengine 2.x is not supported. Added `TDengine.Impl.GetData()` interface to deserialize query results. | | 1.0.7 | Fixed TDengine.Query() memory leak. | | 1.0.6 | Fix schemaless bug in 1.0.4 and 1.0.5. |