Fluent.Unions.MongoDB
1.1.0
dotnet add package Fluent.Unions.MongoDB --version 1.1.0
NuGet\Install-Package Fluent.Unions.MongoDB -Version 1.1.0
<PackageReference Include="Fluent.Unions.MongoDB" Version="1.1.0" />
<PackageVersion Include="Fluent.Unions.MongoDB" Version="1.1.0" />
<PackageReference Include="Fluent.Unions.MongoDB" />
paket add Fluent.Unions.MongoDB --version 1.1.0
#r "nuget: Fluent.Unions.MongoDB, 1.1.0"
#:package Fluent.Unions.MongoDB@1.1.0
#addin nuget:?package=Fluent.Unions.MongoDB&version=1.1.0
#tool nuget:?package=Fluent.Unions.MongoDB&version=1.1.0
![]()
Fluent.Unions.MongoDB
Stores Option<T> in MongoDB documents as its value or BSON null, with a BSON serializer for the official MongoDB .NET driver. It builds on Fluent.Unions and MongoDB.Bson (Apache-2.0).
Installation
dotnet add package Fluent.Unions.MongoDB
Usage
Register once at startup, before the first class map is created. No attribute is needed on properties.
using Fluent.Unions;
using Fluent.Unions.MongoDB;
using MongoDB.Bson;
FluentUnionsBson.Register();
public class Customer
{
public string Name { get; set; } = "";
public Option<string> Nickname { get; set; }
}
new Customer { Name = "Ada", Nickname = Option.None }.ToBsonDocument(); // { "Name" : "Ada", "Nickname" : null }
None is written as BSON null. Reading BSON null or a missing element gives an option without a value. To leave out the element instead, register OmitNoneConvention in a ConventionPack.
Result, Result<T> and your own result types declared with [FluentResult<TError>], are not serialized: the serializer throws NotSupportedException, because an error would expose exception details. Convert a result first.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Fluent.Unions (>= 1.1.0)
- MongoDB.Bson (>= 3.14.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.