Shuttle.Recall 16.1.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
.NET Standard 2.0
dotnet add package Shuttle.Recall --version 16.1.1
NuGet\Install-Package Shuttle.Recall -Version 16.1.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="Shuttle.Recall" Version="16.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Shuttle.Recall --version 16.1.1
#r "nuget: Shuttle.Recall, 16.1.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Shuttle.Recall as a Cake Addin
#addin nuget:?package=Shuttle.Recall&version=16.1.1

// Install Shuttle.Recall as a Cake Tool
#tool nuget:?package=Shuttle.Recall&version=16.1.1

Shuttle.Recall

A .Net event-sourcing mechanism.

Documentation

If you would like to give Shuttle.Recall a spin you can head over to our documentation site.

Getting Started

This guide demonstrates using Shuttle.Recall with a Sql Server implementation.

Start a new Console Application project called RecallQuickstart and select a Shuttle.Recall implementation:

PM> Install-Package Shuttle.Recall.Sql.Storage

This provides a SQL-based store for doamin events.

Install the System.Data.SqlClient nuget package.

This will provide a connection to our Sql Server.

Now we'll define the domain event that will represent a state change in the Name attribute:

public class Renamed
{
    public string Name { get; set; }
}

Next we'll create our Aggregate Root. In a real-world scenario the aggregate in our domain would be something like Customer, Member, Invoice, and so forth. The aggregate will make use of an EventStream to save the changes in the state:

using System;
using System.Collections.Generic;

namespace RecallQuickstart
{
    public class AggregateRoot
    {
        public Guid Id { get; }
        public string Name { get; private set; }

        public List<string> AllNames { get; } = new List<string>();

        public AggregateRoot(Guid id)
        {
            Id = id;
        }

        public Renamed Rename(string name)
        {
            return On(new Renamed
            {
                Name = name
            });
        }

        private Renamed On(Renamed renamed)
        {
            Name = renamed.Name;

            AllNames.Add(Name);

            return renamed;
        }
    }
}

Create a new Sql Server database called RecallQuickstart to store our events and execute the following creation script against that database:

%userprofile%\.nuget\packages\shuttle.recall.sql.storage\{version}\scripts\System.Data.SqlClient\EventStoreCreate.sql

Next we'll use event sourcing to store an rehydrate our aggregate root from the Main() entry point:

using System.Data.Common;
using System.Data.SqlClient;
using Microsoft.Extensions.DependencyInjection;
using Shuttle.Core.Data;
using Shuttle.Recall;
using Shuttle.Recall.Sql.Storage;

namespace RecallQuickstart
{
    internal class Program
    {
        static void Main(string[] args)
        {
            DbProviderFactories.RegisterFactory("System.Data.SqlClient", SqlClientFactory.Instance);

            var services = new ServiceCollection();

            services
                .AddDataAccess(builder =>
                {
                    builder.AddConnectionString("EventStore", "System.Data.SqlClient",
                        "Data Source=.;Initial Catalog=RecallQuickstart;user id=sa;password=Pass!000");

                    builder.Options.DatabaseContextFactory.DefaultConnectionStringName = "EventStore";
                })
                .AddSqlEventStorage()
                .AddEventStore();

            var provider = services.BuildServiceProvider();

            var databaseContextFactory = provider.GetRequiredService<IDatabaseContextFactory>();
            var store = provider.GetRequiredService<IEventStore>();

            var id = Guid.NewGuid();

            // we can very easily also add unit tests for our aggregate in a separate project... done here as an example
            var aggregateRoot1 = new AggregateRoot(id);
            var stream1 = store.CreateEventStream(id);

            stream1.AddEvent(aggregateRoot1.Rename("Name-1"));
            stream1.AddEvent(aggregateRoot1.Rename("Name-2"));
            stream1.AddEvent(aggregateRoot1.Rename("Name-3"));
            stream1.AddEvent(aggregateRoot1.Rename("Name-4"));
            stream1.AddEvent(aggregateRoot1.Rename("Name-5"));

            if (aggregateRoot1.AllNames.Count != 5)
            {
                throw new ApplicationException();
            }

            if (!aggregateRoot1.Name.Equals("Name-5"))
            {
                throw new ApplicationException();
            }

            using (databaseContextFactory.Create("EventStore"))
            {
                store.Save(stream1);
            }

            var aggregateRoot2 = new AggregateRoot(id);

            EventStream stream2;

            using (databaseContextFactory.Create("EventStore"))
            {
                stream2 = store.Get(id);
            }

            stream2.Apply(aggregateRoot2);

            if (aggregateRoot2.AllNames.Count != 5)
            {
                throw new ApplicationException();
            }

            if (!aggregateRoot2.Name.Equals("Name-5"))
            {
                throw new ApplicationException();
            }
        }
    }
}

Once you have executed the program you'll find the 5 relevant entries in the EventStore table in the database.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Shuttle.Recall:

Package Downloads
Shuttle.Recall.Sql.Storage The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Sql-based implementation of the event store Shuttle.Recall persistence interfaces.

Shuttle.Esb.Process The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Shuttle.Esb process management using Shuttle.Recall event sourcing.

Shuttle.Recall.Sql.EventProcessing The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Sql-based implementation of the event store Shuttle.Recall projection interfaces.

Shuttle.Recall.Tests The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Tests to exercise Shuttle.Recall component implementations.

Shuttle.Access.Sql The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Provides Sql-based implementation of data access components for use with Shuttle.Access implementations.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
16.1.1 0 12/1/2022
16.0.0 666 9/4/2022
14.0.0 760 5/29/2022
13.1.0 599 5/6/2022
13.0.1 977 4/9/2022
13.0.0 614 3/21/2022
12.0.5 220 1/22/2022
12.0.3 1,487 2/4/2021
12.0.2 400 1/17/2021
12.0.1 754 11/8/2020
11.1.0 669 9/1/2020
11.0.0 933 8/21/2019
10.2.1 1,300 5/27/2019
10.1.4 706 9/22/2018
10.1.3 1,350 9/16/2018
10.0.3 851 8/7/2018
10.0.2 845 7/8/2018
10.0.0 2,560 2/13/2018
8.2.2 1,317 8/6/2017
8.2.1 1,714 7/2/2017
8.1.3 1,252 7/1/2017
8.0.1 840 5/15/2017
8.0.0 1,121 3/24/2017
4.0.0 880 10/2/2016
3.6.2 1,168 6/4/2016
3.6.1 844 6/4/2016
3.6.0 865 5/18/2016
3.5.2 1,460 4/23/2016
3.5.1 1,313 3/23/2016