Skip to content

Commit a370fb2

Browse files
authored
Updated
Updated
1 parent d3ee977 commit a370fb2

File tree

1 file changed

+28
-41
lines changed

1 file changed

+28
-41
lines changed

docs/integrations/language-clients/csharp.md

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,34 @@ Install-Package ClickHouse.Driver
5252

5353
---
5454

55-
## Usage {#usage}
56-
57-
### Creating a Connection {#creating-a-connection}
55+
## Quick Start {#quick-start}
5856

59-
Create a connection using a connection string:
6057
```csharp
6158
using ClickHouse.Driver.ADO;
6259

63-
var connectionString = "Host=localhost;Protocol=http;Database=default;Username=default;Password=";
60+
using (var connection = new ClickHouseConnection("Host=my.clickhouse;Protocol=https;Port=8443;Username=user"))
61+
{
62+
var version = await connection.ExecuteScalarAsync("SELECT version()");
63+
Console.WriteLine(version);
64+
}
65+
```
6466

65-
using (var connection = new ClickHouseConnection(connectionString))
67+
Using **Dapper**:
68+
```csharp
69+
using Dapper;
70+
using ClickHouse.Driver.ADO;
71+
72+
using (var connection = new ClickHouseConnection("Host=my.clickhouse"))
6673
{
67-
connection.Open();
74+
var result = await connection.QueryAsync<string>("SELECT name FROM system.databases");
75+
Console.WriteLine(string.Join('\n', result));
6876
}
6977
```
7078

7179
---
7280

81+
## Usage {#usage}
82+
7383
### Connection String Parameters {#connection-string}
7484

7585
| Parameter | Description | Default |
@@ -189,7 +199,7 @@ Console.WriteLine($"Rows written: {bulkCopy.RowsWritten}");
189199

190200
**Notes:**
191201

192-
* To make best use of ClickHouse properties, `ClickHouseBulkCopy` utilizes TPL to process batches of data, with up to 4 parallel insertion tasks (tweakable).
202+
* For optimal performance, ClickHouseBulkCopy uses the Task Parallel Library (TPL) to process batches of data, with up to 4 parallel insertion tasks (tweakable).
193203
* Column names can be optionally provided via `ColumnNames` property if source data has fewer columns than target table.
194204
* Configurable parameters: `Columns`, `BatchSize`, `MaxDegreeOfParallelism`.
195205
* Before copying, a `SELECT * FROM <table> LIMIT 0` query is performed to get information about target table structure. Types of provided objects must reasonably match the target table.
@@ -202,7 +212,7 @@ Console.WriteLine($"Rows written: {bulkCopy.RowsWritten}");
202212
Execute SELECT queries and process results:
203213

204214
```csharp
205-
using ClickHouse.Client.ADO;
215+
using ClickHouse.Driver.ADO;
206216
using System.Data;
207217

208218
using (var connection = new ClickHouseConnection(connectionString))
@@ -304,11 +314,11 @@ INSERT INTO table VALUES ({val1:Int32}, {val2:Array(UInt8)})
304314

305315
`ClickHouse.Driver` supports the following ClickHouse data types with their corresponding .NET type mappings:
306316

307-
### Boolean Types
317+
### Boolean Types {#boolean-types}
308318

309319
* `Bool``bool`
310320

311-
### Numeric Types
321+
### Numeric Types {#numeric-types}
312322

313323
**Signed Integers:**
314324
* `Int8``sbyte`
@@ -337,31 +347,31 @@ INSERT INTO table VALUES ({val1:Int32}, {val2:Array(UInt8)})
337347
* `Decimal128``decimal`
338348
* `Decimal256``BigDecimal`
339349

340-
### String Types
350+
### String Types {#string-types}
341351

342352
* `String``string`
343353
* `FixedString``string`
344354

345-
### Date and Time Types
355+
### Date and Time Types {#date-time-types}
346356

347357
* `Date``DateTime`
348358
* `Date32``DateTime`
349359
* `DateTime``DateTime`
350360
* `DateTime32``DateTime`
351361
* `DateTime64``DateTime`
352362

353-
### Network Types
363+
### Network Types {#network-types}
354364

355365
* `IPv4``IPAddress`
356366
* `IPv6``IPAddress`
357367

358-
### Geographic Types
368+
### Geographic Types {#geographic-types}
359369

360370
* `Point``Tuple`
361371
* `Ring``Array of Points`
362372
* `Polygon``Array of Rings`
363373

364-
### Complex Types
374+
### Complex Types {#complex-types}
365375

366376
* `Array(T)``Array of any type`
367377
* `Tuple(T1, T2, ...)``Tuple of any types`
@@ -393,6 +403,8 @@ You can set defaults using environment variables:
393403
| `CLICKHOUSE_USER` | Default username |
394404
| `CLICKHOUSE_PASSWORD` | Default password |
395405

406+
**Note:** Values provided explicitly to the `ClickHouseConnection` constructor will take priority over environment variables.
407+
396408
---
397409

398410
### ORM & Dapper Support {#orm-support}
@@ -414,28 +426,3 @@ connection.QueryAsync<string>(
414426
new { p1 = 42 }
415427
);
416428
```
417-
418-
---
419-
420-
### Quick Start {#quick-start}
421-
```csharp
422-
using ClickHouse.Driver.ADO;
423-
424-
using (var connection = new ClickHouseConnection("Host=my.clickhouse;Protocol=https;Port=8443;Username=user"))
425-
{
426-
var version = await connection.ExecuteScalarAsync("SELECT version()");
427-
Console.WriteLine(version);
428-
}
429-
```
430-
431-
Using **Dapper**:
432-
```csharp
433-
using Dapper;
434-
using ClickHouse.Driver.ADO;
435-
436-
using (var connection = new ClickHouseConnection("Host=my.clickhouse"))
437-
{
438-
var result = await connection.QueryAsync<string>("SELECT name FROM system.databases");
439-
Console.WriteLine(string.Join('\n', result));
440-
}
441-
```

0 commit comments

Comments
 (0)