ClickHouse.Facades 1.0.8

dotnet add package ClickHouse.Facades --version 1.0.8
NuGet\Install-Package ClickHouse.Facades -Version 1.0.8
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ClickHouse.Facades" Version="1.0.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ClickHouse.Facades --version 1.0.8
#r "nuget: ClickHouse.Facades, 1.0.8"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ClickHouse.Facades as a Cake Addin
#addin nuget:?package=ClickHouse.Facades&version=1.0.8

// Install ClickHouse.Facades as a Cake Tool
#tool nuget:?package=ClickHouse.Facades&version=1.0.8

ClickHouse.Facades

Raw SQL migrations and contexts for ClickHouse referencing ClickHouse.Client

Latest version License

Key Features

  • Migrations: allows you to perform raw SQL migrations on your ClickHouse database.
    • Rollback support
    • Fully async contract
  • Contexts: provides a way to work with ClickHouse contexts, allowing you to organize your database operations in a structured manner.
    • Per context migrations, allowing separate migration management for distinct packages or components
    • Parametrized queries (anonyomous type parameters supported)
    • Provides all the features of the ClickHouse.Client package
    • Fully async contract
  • Testing toolkit: seamlessly integrate unit testing into your ClickHouse.Facades components using the dedicated ClickHouse.Facades.Testing package. Test ClickHouse contexts and facades effectively, mock facades or specific database requests, and monitor interactions with the ClickHouse database using the provided testing tools.

Migrations Usage

Implement IClickHouseMigrationInstructions and IClickHouseMigrationsLocator (example) and register them as DI services

services.AddClickHouseMigrations<ClickHouseMigrationInstructions, ClickHouseMigrationsLocator>();

You can request IClickHouseMigrator service or use IServiceProviderExtensions to manage migrations

await serviceProvider.ClickHouseMigrateAsync();

Add Migrations

Add ClickHouseMigration inheritor with ClickHouseMigration attribute

[ClickHouseMigration(202310240941, "ExampleMigration")]
public class ExampleMigration : ClickHouseMigration
{
    protected override void Up(ClickHouseMigrationBuilder migrationBuilder)
    {
        // migrationBuilder.AddRawSqlStatement("create table if not exists ...")
    }

    protected override void Down(ClickHouseMigrationBuilder migrationBuilder)
    {
        // migrationBuilder.AddRawSqlStatement("drop table if exists ...")
    }
}

The index of ClickHouseMigrationAttribute is used to order migrations. It's best to always use idempotent statements (for example with if [not] exists) since migration may fail.

Context Usage

Implement the following class inheritors: ClickHouseContext<TContext>, ClickHouseContextFactory<TContext>, ClickHouseFacade<TContext> (example) and register them as DI services

services.AddClickHouseContext<ExampleContext, ExampleContextFactory>(builder => builder
    .AddFacade<UsersFacade>()
    .AddFacade<OrdersFacade>());

Request IClickHouseContextFactory<TContext> service to create context

await using var context = contextFactory.CreateContext();

var ordersFacade = context.GetFacade<OrdersFacade>();

await ordersFacade.GetOrders();

You can create as many contexts as you need with any number of facades. Facades are built via DI and are stateful within context lifetime.

Note: You can perform migrations on your ClickHouse database without the necessity of implementing contexts.

Documentation

Documentation will be presented in repository Wiki (WIP)

Product 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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ClickHouse.Facades:

Package Downloads
ClickHouse.Facades.Testing

Provides tools for unit testing ClickHouse.Facades components

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8 113 4/18/2024
1.0.7 108 4/17/2024
1.0.6 114 3/26/2024
1.0.5 87 3/21/2024
1.0.4 135 2/22/2024
1.0.3 98 2/5/2024
1.0.2 227 11/2/2023
1.0.1 123 11/2/2023
1.0.0 90 10/26/2023