![]() |
VOOZH | about |
dotnet add package NEventStore.Persistence.MongoDB --version 12.1.0
NuGet\Install-Package NEventStore.Persistence.MongoDB -Version 12.1.0
<PackageReference Include="NEventStore.Persistence.MongoDB" Version="12.1.0" />
<PackageVersion Include="NEventStore.Persistence.MongoDB" Version="12.1.0" />Directory.Packages.props
<PackageReference Include="NEventStore.Persistence.MongoDB" />Project file
paket add NEventStore.Persistence.MongoDB --version 12.1.0
#r "nuget: NEventStore.Persistence.MongoDB, 12.1.0"
#:package NEventStore.Persistence.MongoDB@12.1.0
#addin nuget:?package=NEventStore.Persistence.MongoDB&version=12.1.0Install as a Cake Addin
#tool nuget:?package=NEventStore.Persistence.MongoDB&version=12.1.0Install as a Cake Tool
Mongo Persistence Engine for NEventStore
NEventStore.Persistence.MongoDB currently supports:
Branches:
ChangeLog can be found
git clone --recursive https://github.com/NEventStore/NEventStore.Persistence.MongoDB.git
or
git clone https://github.com/NEventStore/NEventStore.Persistence.MongoDB.git
git submodule update
To build the project locally on a Windows Machine:
.\src\.nuget\NEventStore.Persistence.MongoDB.nuspec file if needed (before creating relase packages).build.ps1 in the root of the repository.Install Database engines or use Docker to run them in a container (you can use the scripts in ./docker folder).
Define the following environment variables:
NEventStore.MongoDB="mongodb://localhost:50002/NEventStore"
dotnet build .\src\NEventStore.Persistence.MongoDB.Benchmark\NEventStore.Persistence.MongoDB.Benchmark.csproj -c Release
$env:NEventStore.MongoDB = 'mongodb://localhost:50002/NEventStore'
dotnet .\src\NEventStore.Persistence.MongoDB.Benchmark\bin\Release\net8.0\NEventStore.Persistence.MongoDB.Benchmark.dll --list flat
dotnet .\src\NEventStore.Persistence.MongoDB.Benchmark\bin\Release\net8.0\NEventStore.Persistence.MongoDB.Benchmark.dll --filter *
dotnet .\src\NEventStore.Persistence.MongoDB.Benchmark\bin\Release\net8.0\NEventStore.Persistence.MongoDB.Benchmark.dll --filter *CheckpointGeneratorBenchmarks*
dotnet .\src\NEventStore.Persistence.MongoDB.Benchmark\bin\Release\net8.0\NEventStore.Persistence.MongoDB.Benchmark.dll --filter *ReadFromEventStoreAsyncBenchmarks.ReadFromEventStoreAsync*
To run tests in visual studio using NUnit as a Test Runner you need to explicitly exclude "Explicit Tests" from running adding the following filter in the test explorer section:
-Trait:"Explicit"
Pay attention to GUID serialization and deserialization, MongoDB driver uses a specific representation for GUIDs.
Up to MongoDb 2.30.0 the driver uses the CSharpLegacy representation for GUIDs (drivers for other languages use a different byte ordering).
From 3.0.0 the driver default to the Standard representation (which has the same byte ordering in all the different drivers).
The CommitId of each CommitAttempt is actually a GUID, to guarantee compatibility for old projects you should to use the CSharpLegacy representation,
you can do this either by:
Configuring a GUID Serializer globally for the MongoDB driver:
BsonSerializer.RegisterSerializer(new GuidSerializer(GuidRepresentation.CSharpLegacy));
Customizing the serialization for the CommitId property of the MongoCommit class (see below):
BsonClassMap.RegisterClassMap<MongoCommit>(cm =>
{
cm.AutoMap();
cm.GetMemberMap(c => c.CommitId).SetSerializer(new GuidSerializer(GuidRepresentation.CSharpLegacy));
});
To serialize GUIDs in Lists or Dictionary of objects, you should also remember to properly set the Guid representation for the object serializer, with something like:
BsonSerializer.RegisterSerializer(new ObjectSerializer(
BsonSerializer.LookupDiscriminatorConvention(typeof(object)), GuidRepresentation.CSharpLegacy, ObjectSerializer.AllAllowedTypes));
Reference:
You can configure the serialization process using the standard methods offered by the MongoDB C# driver.
You'll need to specify the class mapping or implement an IBsonSerializationProvider for the MongoCommit class and register it before you start using any database operation.
For detailed information on how to configure the serialization in MongoDB head to the official Serialization page.
public static void MapMongoCommit()
{
if (!BsonClassMap.IsClassMapRegistered(typeof(MongoCommit)))
{
BsonClassMap.RegisterClassMap<MongoCommit>(cm =>
{
cm.AutoMap();
// change how the Headers collection is serialized
cm.MapMember(c => c.Headers)
.SetSerializer(
new ImpliedImplementationInterfaceSerializer<IDictionary<string, object>, Dictionary<string, object>>()
.WithImplementationSerializer(
new DictionaryInterfaceImplementerSerializer<Dictionary<string, object>>(global::MongoDB.Bson.Serialization.Options.DictionaryRepresentation.Document)
));
// your custom mapping goes here
});
}
}
class MongoCommitProvider : IBsonSerializationProvider
{
public IBsonSerializer GetSerializer(Type type)
{
if (type == typeof(MongoCommit))
{
return new MongoCommitSerializer();
}
return null;
}
}
class MongoCommitSerializer : SerializerBase<MongoCommit>
{
public override MongoCommit Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
{
// read the BsonDocument manually and return an instance of the MongoCommit class
}
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, int value)
{
// write the BsonDocument manually serializing each property of the MongoCommit class
}
}
You can then register the serialization provider using: BsonSerializer.RegisterSerializationProvider
This repository uses GitFlow to develop, if you are not familiar with GitFlow you can look at the following link.
Probably the most straightforward way to install GitFlow on your machine is installing Git Command Line, then install the Visual Studio Plugin for Git-Flow. This plugin is accessible from the Team Explorer menu and allows you to install GitFlow extension directly from Visual Studio with a simple click. The installer installs standard GitFlow extension both for command line and for Visual Studio Plugin.
Once installed you can use GitFlow right from Visual Studio or from Command line, which one you prefer.
Build machine uses GitVersion to manage automatic versioning of assemblies and Nuget Packages. You need to be aware that there are a rule that does not allow you to directly commit on master, or the build will fail.
A commit on master can be done only following the Git-Flow model, as a result of a new release coming from develop, or with an hotfix.
Just clone the repository and from command line checkout develop branch with
git checkout develop
Then from command line run GitFlow initialization scripts
git flow init
You can leave all values as default. Now your repository is GitFlow enabled.
Remember to update .\src\.nuget\NEventStore.Persistence.MongoDB.nuspec file if needed (before creating relase packages).
The .nuspec file is needed because the new dotnet pack command has problems dealing with ProjectReferences, submodules get the wrong version number.
While we are on develop branch, (suppose we just bumped major number so the driver version number is 6.0.0-unstablexxxx), we need to declare that this persistence driver depends from a version greater than the latest published. If the latest version of NEventStore 5.x.x wave iw 5.4.0 we need to declare this package dependency as
(5.4, 7)
This means, that we need a NEventStore greater than the latest published, but lesser than the next main version. This allows version 6.0.0-unstable of NEventStore to satisfy the dependency. We remember that prerelease package are considered minor than the stable package. Es.
5.4.0 5.4.1 6.0.0-unstable00001 6.0.0
| 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 is compatible. 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 is compatible. 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 is compatible. 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 is compatible. 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 | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net472 net472 is compatible. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | 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 |
|---|---|---|
| 12.1.0 | 95 | 6/15/2026 |
| 12.0.0 | 2,871 | 1/24/2025 |
| 11.0.0 | 277 | 12/9/2024 |
| 11.0.0-beta.1 | 149 | 11/7/2024 |
| 10.0.1 | 346 | 10/24/2024 |
| 10.0.0 | 259 | 9/27/2024 |
| 10.0.0-beta.1 | 143 | 8/31/2024 |
| 9.1.2 | 6,625 | 12/19/2023 |
| 9.1.1 | 9,837 | 8/1/2023 |
| 9.0.1 | 16,590 | 12/29/2021 |
| 9.0.0 | 1,913 | 12/3/2021 |
| 8.0.0 | 18,576 | 12/18/2020 |
| 7.0.0 | 26,452 | 7/17/2019 |
| 6.0.0 | 12,723 | 3/27/2019 |
| 6.0.0-rc-1 | 1,760 | 2/15/2019 |
| 6.0.0-rc-0 | 1,904 | 12/19/2018 |
| 5.3.7 | 10,174 | 10/19/2016 |
| 5.3.6 | 2,137 | 9/30/2016 |
| 5.3.5 | 2,253 | 8/22/2016 |
| 5.2.0 | 7,695 | 5/23/2015 |