Xpandables.Events.Data 10.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Xpandables.Events.Data --version 10.0.1
                    
NuGet\Install-Package Xpandables.Events.Data -Version 10.0.1
                    
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="Xpandables.Events.Data" Version="10.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Xpandables.Events.Data" Version="10.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Xpandables.Events.Data" />
                    
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 Xpandables.Events.Data --version 10.0.1
                    
#r "nuget: Xpandables.Events.Data, 10.0.1"
                    
#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 Xpandables.Events.Data@10.0.1
                    
#: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=Xpandables.Events.Data&version=10.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Xpandables.Events.Data&version=10.0.1
                    
Install as a Cake Tool

System.Events.Data

NuGet NuGet Downloads .NET License

ADO.NET persistence for event sourcing with System.Events.

Overview

System.Events.Data provides ADO.NET implementations for the event store, outbox, and inbox abstractions defined in System.Events. It uses System.Data (IDataRepository, IDataUnitOfWork) for raw ADO.NET persistence with SQL scripts for table creation across SQL Server, PostgreSQL, and SQLite.

Built for .NET 10. Does not use Entity Framework Core.

Features

Event Store

  • EventStore<TDomain, TSnapshot> — ADO.NET event store implementing IEventStore
  • Supports append, read, subscribe, truncate, and delete stream operations

Outbox/Inbox Stores

  • OutboxStore<TOutbox> — ADO.NET outbox implementing IOutboxStore
  • InboxStore<TInbox> — ADO.NET inbox implementing IInboxStore

Data Entities

  • DataEvent — Base entity for event records
  • DataEventDomain — Domain event entity (IDataEventDomain)
  • DataEventSnapshot — Snapshot event entity (IDataEventSnapshot)
  • DataEventOutbox — Outbox event entity (IDataEventOutbox)
  • DataEventInbox — Inbox event entity (IDataEventInbox)

Event Converters

  • IEventConverter<TDataEvent, TEvent> — Convert between data entities and event types
  • IEventConverterFactory — Factory for obtaining converters
  • EventConverterFactory — Default factory implementation
  • EventConverterDomain — Domain event converter
  • EventConverterSnapshot — Snapshot event converter
  • EventConverterOutbox — Outbox event converter
  • EventConverterInbox — Inbox event converter
  • IEventConverterContext — Shared context for converters
  • DefaultEventConverterContext — Default converter context

SQL Scripts

  • IEventTableScriptProvider — Provides SQL scripts for creating/dropping event tables
  • SqlServerEventTableScripts — SQL Server table scripts
  • PostgreSqlEventTableScripts — PostgreSQL table scripts
  • SqliteEventTableScripts — SQLite table scripts
  • EventTableScriptExporter — Export scripts to files

Installation

dotnet add package Xpandables.Events.Data

Dependencies: System.Events, System.Data

Quick Start

Register Services

using Microsoft.Extensions.DependencyInjection;

// Register all event stores (EventStore, OutboxStore, InboxStore)
services.AddXEventStores();

// Or register individually
services.AddXEventStore();
services.AddXOutboxStore();
services.AddXInboxStore();

// Register converter factory and context
services.AddXEventConverterFactory();
services.AddXEventConverterContext();

Create Database Tables

using System.Events.Data.Scripts;

// Get SQL scripts for your database
var scripts = new SqlServerEventTableScripts();
string createScript = scripts.GetCreateAllTablesScript(schema: "Events");
string dropScript = scripts.GetDropAllTablesScript(schema: "Events");

// Or use PostgreSQL/SQLite
var pgScripts = new PostgreSqlEventTableScripts();
var sqliteScripts = new SqliteEventTableScripts();

Use the Event Store

using System.Events.Domain;
using System.Events.Data;

public class OrderService(IEventStore eventStore)
{
    public async Task CreateOrderAsync(
        Guid orderId, CancellationToken ct)
    {
        var request = new AppendRequest
        {
            StreamId = orderId,
            Events = [new OrderCreated { StreamId = orderId }]
        };

        AppendResult result = await eventStore
            .AppendToStreamAsync(request, ct);
    }

    public async Task<List<IDomainEvent>> GetEventsAsync(
        Guid streamId, CancellationToken ct)
    {
        var request = new ReadStreamRequest
        {
            StreamId = streamId,
            FromVersion = 0
        };

        var events = new List<IDomainEvent>();
        await foreach (var envelope in eventStore
            .ReadStreamAsync(request, ct))
        {
            events.Add(envelope.Event);
        }
        return events;
    }
}

Core Types

Type Description
EventStore<TDomain, TSnapshot> ADO.NET event store
OutboxStore<TOutbox> ADO.NET outbox store
InboxStore<TInbox> ADO.NET inbox store
DataEventDomain Domain event data entity
DataEventSnapshot Snapshot data entity
DataEventOutbox Outbox data entity
DataEventInbox Inbox data entity
IEventConverterFactory Converter factory
IEventTableScriptProvider SQL script provider

DI Extension Methods

Method Description
AddXEventStores() Register all stores (EventStore, Outbox, Inbox)
AddXEventStore() Register EventStore only
AddXOutboxStore() Register OutboxStore only
AddXInboxStore() Register InboxStore only
AddXEventConverterFactory() Register event converter factory
AddXEventConverterContext() Register default converter context

Package Description
Xpandables.Events Core event sourcing abstractions
Xpandables.Data ADO.NET repository and unit of work

📄 License

Apache License 2.0 — Copyright © Kamersoft 2025

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 (1)

Showing the top 1 NuGet packages that depend on Xpandables.Events.Data:

Package Downloads
Xpandables.AspNetCore.Events

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.2 114 3/15/2026
10.0.1 103 2/20/2026
10.0.0 121 1/9/2026