Ksql.Linq 0.9.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ksql.Linq --version 0.9.6
                    
NuGet\Install-Package Ksql.Linq -Version 0.9.6
                    
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="Ksql.Linq" Version="0.9.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ksql.Linq" Version="0.9.6" />
                    
Directory.Packages.props
<PackageReference Include="Ksql.Linq" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ksql.Linq --version 0.9.6
                    
#r "nuget: Ksql.Linq, 0.9.6"
                    
#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.
#:package Ksql.Linq@0.9.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ksql.Linq&version=0.9.6
                    
Install as a Cake Addin
#tool nuget:?package=Ksql.Linq&version=0.9.6
                    
Install as a Cake Tool

Overview

Ksql.Linq is a C# library that unifies Kafka/ksqlDB and Avro/Schema Registry usage. It lets you control Kafka Streams and ksqlDB in a LINQ style and offers the following capabilities.

  • Operate Kafka and ksqlDB through a LINQ-based DSL.
  • Design type-safe schemas with Avro and Schema Registry.
  • Detect Streams/Tables and Pull/Push modes automatically.
  • Support operations with DLQ, retry, and commit helpers.
  • Self-healing persistent queries: automatically stabilizes CTAS/CSAS queries by retrying, pre-creating internal topics, and recovering from transient errors.
  • Market-schedule–aware OHLC bars (support feature): Generate OHLC bars (e.g., 1s/1m/5m/15m/1h) strictly aligned to exchange trading sessions. The engine skips closed hours and holidays, handles DST correctly, and offers gap policies (skip, carry-forward close, or emit sentinel). Pre-/post-market can be toggled per schedule.

New in 0.9.6 – Runtime tuning via appsettings

Several operational parameters are now controllable via KsqlDsl options in appsettings.json:

  • DDL retry behavior
    • KsqlDdlRetryCount / KsqlDdlRetryInitialDelayMs: control how many times and how often CREATE/CSAS/CTAS is retried when ksqlDB is not ready.
  • Persistent query RUNNING detection
    • KsqlQueryRunningConsecutiveCount: required number of consecutive RUNNING observations in SHOW QUERIES.
    • KsqlQueryRunningPollIntervalMs: interval between SHOW QUERIES checks.
    • KsqlQueryRunningStabilityWindowSeconds: extra stability window after RUNNING is reached.
    • KsqlQueryRunningTimeoutSeconds: overall timeout for waiting a query to reach RUNNING.
  • Warmup and metadata visibility
    • KsqlSimpleEntityWarmupSeconds / KsqlQueryEntityWarmupSeconds: warmup windows before issuing DDL for simple/query-defined entities.
    • KsqlEntityDdlVisibilityTimeoutSeconds: how long to wait for ksqlDB metadata (SHOW TABLES/STREAMS) to reflect new entities. For more details , see the wiki: https://github.com/synthaicode/Ksql.Linq/wiki/Runtime-Tuning-Plan-v0-9-6

New in 0.9.5 – Design-time KSQL & CLI

  • Design-time KSQL generation: create full KSQL scripts (CREATE STREAM/TABLE, CSAS/CTAS, SELECT …) from your KsqlContext without running Kafka/ksqlDB.
  • Design-time Avro export: export value Avro schemas for all entities from the mapping model (no live Schema Registry required).
  • Design-time factory: implement IDesignTimeKsqlContextFactory to create a special KsqlContext that skips runtime connections and focuses on the model.
  • Ksql.Linq.Cli .NET tool: use dotnet ksql script and dotnet ksql avro against a compiled DLL or project to generate SQL scripts and .avsc files. Published on NuGet as Ksql.Linq.Cli (https://www.nuget.org/packages/Ksql.Linq.Cli).
  • Traceable scripts: generated KSQL includes comments with the Ksql.Linq version, target assembly name/version, generation timestamp, Schema Registry subject, and CLR namespace.

Documentation

For full documentation, advanced usage, and design notes, see the project wiki:

Ksql.Linq Wiki
https://github.com/synthaicode/Ksql.Linq/wiki

Minimal Quick Start

NOTE: In this repo's docker-compose test environment, use
127.0.0.1:39092 (Kafka) / 18081 (Schema Registry) / 18088 (ksqlDB).
Samples below align to these ports. Adjust URLs when using external services.

This document is a minimal quick start guide for Ksql.Linq NuGet consumers.


Prerequisites

  • .NET 8 SDK
  • Kafka / Schema Registry / ksqlDB running

Minimal appsettings.json

{
  "KsqlDsl": {
    "Common": {
      "BootstrapServers": "127.0.0.1:39092",
      "ClientId": "my-app"
    },
    "SchemaRegistry": {
      "Url": "http://127.0.0.1:18081"
    },
    "KsqlDbUrl": "http://127.0.0.1:18088"
  }
}

Minimal code (produce / consume)

using Ksql.Linq;
using Ksql.Linq.Core.Attributes;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

[KsqlTopic("quickstart-basic")]
public class Hello
{
    public int Id { get; set; }
    public string Text { get; set; } = "";
}

public class AppCtx : KsqlContext
{
    public AppCtx(IConfiguration cfg, ILoggerFactory? lf = null)
        : base(cfg, lf) { }

    public EventSet<Hello> Hellos { get; set; } = null!;

    protected override void OnModelCreating(IModelBuilder b)
        => b.Entity<Hello>();
}

var cfg = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();

await using var ctx = new AppCtx(
    cfg,
    LoggerFactory.Create(b => b.AddConsole())
);

await ctx.Hellos.AddAsync(new Hello
{
    Id = 1,
    Text = "Hello Ksql.Linq"
});

await ctx.Hellos.ForEachAsync(m =>
{
    Console.WriteLine(m.Text);
    return Task.CompletedTask;
});

Notes

Use KsqlDsl:Topics.{name}.Creation.* to control partitions / retention per topic.

For secured clusters, configure SecurityProtocol / Sasl* under KsqlDsl:Common.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 652 12/1/2025
0.9.8 179 11/24/2025
0.9.7 147 11/23/2025
0.9.6 277 11/21/2025
0.9.5 392 11/19/2025
0.9.4 121 11/16/2025
0.9.3 120 11/16/2025
0.9.2 118 11/16/2025
0.9.1-rc5 256 11/12/2025
0.9.1-rc4 266 11/12/2025

Maintenance release: stability fixes and release automation cleanups. See docs/diff_log/diff_release_v0_9_6_20251122.md for details.