EventSaucing 2.0.7

dotnet add package EventSaucing --version 2.0.7                
NuGet\Install-Package EventSaucing -Version 2.0.7                
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="EventSaucing" Version="2.0.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EventSaucing --version 2.0.7                
#r "nuget: EventSaucing, 2.0.7"                
#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 EventSaucing as a Cake Addin
#addin nuget:?package=EventSaucing&version=2.0.7

// Install EventSaucing as a Cake Tool
#tool nuget:?package=EventSaucing&version=2.0.7                

EventSaucing

Add a little EventSauce to your project 😉

This library brings together different stacks to create an Event Sourcing solution.


Reading list before using the project:

Installing

The latest release of EventSaucing is available on NuGet.

Usage

Once referenced in your project you need to configure it in your Startup inside ConfigureServices.

var builder = new ContainerBuilder();

builder.RegisterEventSaucingModules(new EventSaucingConfiguration {
   ConnectionString = // Set your connection string
});

builder.Populate(services); // Populate your services.

var container = builder.Build();

container.StartEventSaucing(); // Start EventSaucing

You can then construct your Aggregates by inheriting from the Aggregate class and including Apply() methods to handle the raised events on the aggregate.

public class FooAggregate : Aggregate {
  public FooAggregate(Guid id) {
    base.Id = id;
  }

  public int Bar { get; set; }

  public void Create(int bar) {
    RaiseEvent(new FooCreated(bar));
  }

  void Apply(FooCreated @event) {			
    Bar = @event.Bar;
  }
}
// A POCO for the event state
public class FooCreated {
  public FooCreated(int bar) {
    Bar = bar;
  }
  public int Bar { get; }
}

You can then create Projectors by inheriting from ProjectorBase and setting up which events to handle. You must also give each projector a unique number. In this example Dapper is used to interact with the persistence store.

[Projector(1)] // The unique projector id.
public class FooProjector: ProjectorBase {
  readonly ConventionBasedCommitProjecter _conventionProjector;

  public FooProjector(IDbService dbService, IPersistStreams persistStreams):base(persistStreams, dbService) {
    var conventionalDispatcher = new ConventionBasedEventDispatcher(c => Checkpoint = c.ToSome())
      .FirstProject<FooCreated>(OnFooCreated)
      .ThenProject<SomeEvent>(OnSomeEventHandler);

    _conventionProjector = new ConventionBasedCommitProjecter(this, dbService, conventionalDispatcher);
  }

  public override void Project(ICommit commit) {
    _conventionProjector.Project(commit);
  }

  private void OnFooCreated(IDbTransaction tx, ICommit commit, FooCreated @event) {
    var sqlParams = new { 
      Id = commit.AggregateId(), 
      Bar = FooCreated.Bar 
    };

    const string sql = @"
      INSERT INTO [dbo].[FooProjector.Foo]
        ([Id]
        ,[Bar])
      SELECT
        @Id
        ,@Bar
      WHERE NOT EXISTS(SELECT * FROM [dbo].[FooProjector.Foo] WHERE Id = @Id);";
    tx.Connection.Execute(sql, (object)sqlParams, tx);
  }

Dependencies

  • Dapper - Used to interact with the sql persistence store.
  • NEventStore - Used for storage of the event stream.
  • Serilog - Used for logging.
  • Akka.NET - Used to deliver deliver events to aggregates & projectors.
  • Autofac - Used for dependency injection.
  • Scalesque - Used to add functional programming in c#.
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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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

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
2.0.7 91 10/31/2024
2.0.6 348 6/11/2024
2.0.5 105 6/10/2024
2.0.4 165 5/30/2024
2.0.3 445 4/8/2024
2.0.2 192 3/25/2024
2.0.1 239 11/16/2023
2.0.0 114 11/16/2023
1.0.30 115 3/22/2024
1.0.29 443 8/27/2021
1.0.28 364 7/27/2021
1.0.27 424 6/24/2021
1.0.6 706 3/29/2019
1.0.5 786 10/29/2018
1.0.4 1,034 3/6/2018
1.0.3 977 9/20/2017
1.0.2 983 9/7/2017
1.0.1 1,103 8/1/2017

Upgraded Akka version to fix critical bug + minor versions of other dependencies