NEventStore.Persistence.MongoDB 10.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NEventStore.Persistence.MongoDB --version 10.0.0                
NuGet\Install-Package NEventStore.Persistence.MongoDB -Version 10.0.0                
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="NEventStore.Persistence.MongoDB" Version="10.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NEventStore.Persistence.MongoDB --version 10.0.0                
#r "nuget: NEventStore.Persistence.MongoDB, 10.0.0"                
#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 NEventStore.Persistence.MongoDB as a Cake Addin
#addin nuget:?package=NEventStore.Persistence.MongoDB&version=10.0.0

// Install NEventStore.Persistence.MongoDB as a Cake Tool
#tool nuget:?package=NEventStore.Persistence.MongoDB&version=10.0.0                

NEventStore.Persistence.Mongo

Mongo Persistence Engine for NEventStore

NEventStore.Persistence.MongoDB currently supports:

  • .net framework 4.6.2
  • .net standard 2.0

Build Status

Branches:

  • master Build status
  • develop Build status

Information

ChangeLog can be found here

How to Build (locally)

  • clone the repository with:
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:

  • Optional: update .\src\.nuget\NEventStore.Persistence.MongoDB.nuspec file if needed (before creating relase packages).
  • Open a Powershell console in Administrative mode and run the build script build.ps1 in the root of the repository.

How to Run Unit Tests (locally)

  • 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"
    

Run Tests in Visual Studio

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"

Configure / Customize Commit Serialization

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 registerm them before you start using any database operation.

For detailed information on how to configure the serialization in MongoDB head to the official Serialization documentation

BsonClassMap

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
    });
  }
}

IBsonSerializationProvider

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

How to contribute

Git-Flow

This repository uses GitFlow to develop, if you are not familiar with GitFlow you can look at the following link.

Installing and configuring Git Flow

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 and GitVersion

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.

Quick Info for NEventstore projects

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.

Note on Nuget version on Nuspec

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 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 is compatible.  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
11.0.0-beta.1 37 11/7/2024
10.0.1 148 10/24/2024
10.0.0 127 9/27/2024
10.0.0-beta.1 58 8/31/2024
9.1.2 2,813 12/19/2023
9.1.1 4,725 8/1/2023
9.0.1 11,594 12/29/2021
9.0.0 1,681 12/3/2021
8.0.0 14,027 12/18/2020
7.0.0 21,181 7/17/2019
6.0.0 11,050 3/27/2019
6.0.0-rc-1 1,482 2/15/2019
6.0.0-rc-0 1,630 12/19/2018
5.3.7 9,039 10/19/2016
5.3.6 1,714 9/30/2016
5.3.5 1,816 8/22/2016
5.2.0 6,122 5/23/2015
5.2.0-build16-pre 1,498 5/23/2015
5.0.0.106 4,935 4/16/2015
5.0.0.105 1,771 4/11/2015
5.0.0.103 3,957 9/28/2014
5.0.0.101 7,437 6/20/2014
5.0.0.95 1,765 6/18/2014
5.0.0.94 5,016 5/21/2014
5.0.0.92 1,746 5/21/2014
5.0.0.91 1,834 5/10/2014
5.0.0.88 2,149 3/24/2014
5.0.0.86 2,748 3/16/2014
5.0.0-beta 1,552 6/20/2014