-
-
Notifications
You must be signed in to change notification settings - Fork 68
Quick start
Oleg V. Kozlyuk edited this page Nov 3, 2022
·
3 revisions
- Create new console application
- Install ClickHouse.Client package:
dotnet add ClickHouse.Client
orInstall-Package ClickHouse.Client
- Paste following code into Program.cs:
using System;
using System.Threading.Tasks;
using ClickHouse.Client.ADO;
using ClickHouse.Client.Utility;
namespace Clickhouse.Test;
class Program
{
static async Task Main(string[] args)
{
using var connection = new ClickHouseConnection("Host=my.clickhouse;Protocol=https;Port=12345;Username=user");
// ExecuteScalarAsync is an async extension which creates command and executes it
var version = await connection.ExecuteScalarAsync("SELECT version()");
Console.WriteLine(version);
}
}
Example with Dapper:
using System;
using System.Threading.Tasks;
using ClickHouse.Client.ADO;
using Dapper;
namespace Clickhouse.Test;
class Program
{
static async Task Main(string[] args)
{
using var connection = new ClickHouseConnection("Host=my.clickhouse");
string sql = "SELECT * FROM system.table_functions";
var functions = await connection.QueryAsync<string>(sql);
Console.WriteLine(string.Join('\n', functions));
}
}