Noda Time is an alternative date and time API for .NET. It was written by Jon Skeet to solve many flaws of orginal .NET api. Since version 4.0 Npgsql supports and suggests it as recommended way of working with Date and Time.
See more in:
Setup
Marten provides Marten.NodaTime plugin. That provides nessesary setup.
Install it through the Nuget package.
PM> Install-Package Marten.NodaTime
Then call UseNodaTime()
method in your DocumentStore
setup:
var store = DocumentStore.For(_ =>
{
_.Connection(ConnectionSource.ConnectionString);
// sets up NodaTime handling
_.UseNodaTime();
});
By default it also sets up the JsonNetSerializer
options (see more details in NodaTime documentation).
If you're using custom Json serializer or you'd like to maintain fully its configuration then you can set disable default configuration by setting shouldConfigureJsonNetSerializer
parameter to false
. By changing this setting you need to configure NodaTime Json serialization by yourself.
var store = DocumentStore.For(_ =>
{
_.Connection(ConnectionSource.ConnectionString);
_.Serializer<CustomJsonSerializer>();
// sets up NodaTime handling
_.UseNodaTime(shouldConfigureJsonNetSerializer: false);
});