![]() |
VOOZH | about |
dotnet add package EventSaucing --version 2.0.8
NuGet\Install-Package EventSaucing -Version 2.0.8
<PackageReference Include="EventSaucing" Version="2.0.8" />
<PackageVersion Include="EventSaucing" Version="2.0.8" />Directory.Packages.props
<PackageReference Include="EventSaucing" />Project file
paket add EventSaucing --version 2.0.8
#r "nuget: EventSaucing, 2.0.8"
#:package EventSaucing@2.0.8
#addin nuget:?package=EventSaucing&version=2.0.8Install as a Cake Addin
#tool nuget:?package=EventSaucing&version=2.0.8Install as a Cake Tool
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:
The latest release of EventSaucing is available on NuGet.
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);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.8 | 298 | 5/20/2025 |
| 2.0.7 | 1,669 | 10/31/2024 |
| 2.0.6 | 508 | 6/11/2024 |
| 2.0.5 | 229 | 6/10/2024 |
| 2.0.4 | 291 | 5/30/2024 |
| 2.0.3 | 569 | 4/8/2024 |
| 2.0.2 | 309 | 3/25/2024 |
| 2.0.1 | 344 | 11/16/2023 |
| 2.0.0 | 239 | 11/16/2023 |
| 1.0.30 | 277 | 3/22/2024 |
| 1.0.29 | 655 | 8/27/2021 |
| 1.0.28 | 577 | 7/27/2021 |
| 1.0.27 | 619 | 6/24/2021 |
| 1.0.6 | 973 | 3/29/2019 |
| 1.0.5 | 1,082 | 10/29/2018 |
| 1.0.4 | 1,609 | 3/6/2018 |
| 1.0.3 | 1,400 | 9/20/2017 |
| 1.0.2 | 1,380 | 9/7/2017 |
| 1.0.1 | 1,671 | 8/1/2017 |
Upgraded Akka and dapper to latest version