AdaskoTheBeAsT.Dapper.NodaTime 6.0.0

dotnet add package AdaskoTheBeAsT.Dapper.NodaTime --version 6.0.0
                    
NuGet\Install-Package AdaskoTheBeAsT.Dapper.NodaTime -Version 6.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="AdaskoTheBeAsT.Dapper.NodaTime" Version="6.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AdaskoTheBeAsT.Dapper.NodaTime" Version="6.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AdaskoTheBeAsT.Dapper.NodaTime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AdaskoTheBeAsT.Dapper.NodaTime --version 6.0.0
                    
#r "nuget: AdaskoTheBeAsT.Dapper.NodaTime, 6.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.
#:package AdaskoTheBeAsT.Dapper.NodaTime@6.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AdaskoTheBeAsT.Dapper.NodaTime&version=6.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AdaskoTheBeAsT.Dapper.NodaTime&version=6.0.0
                    
Install as a Cake Tool

AdaskoTheBeAsT.Dapper.NodaTime

NuGet

Core Dapper type handlers for NodaTime. This package is provider agnostic: it contains the handlers, the configuration abstraction and portable DbType defaults, and depends only on Dapper and NodaTime.

For a ready-to-use database dialect, install one of the provider packages instead (...SqlServer, ...PostgreSql, ...MySql, ...Sqlite, ...Oracle) - each of them references this package.

Installation

dotnet add package AdaskoTheBeAsT.Dapper.NodaTime

What this package provides

Type Purpose
DapperNodaTimeSetup Registers all handlers with Dapper.SqlMapper in one call
INodaTimeTypeHandlerConfiguration Contract describing how each NodaTime value is written to an IDbDataParameter
NodaTimeTypeHandlerConfigurationBase Portable DbType-only implementation used as the base of every provider dialect
InstantHandler, LocalDateHandler, LocalDateTimeHandler, LocalTimeHandler, OffsetDateTimeHandler, OffsetHandler, DurationHandler, PeriodHandler, CalendarSystemHandler, DateTimeZoneHandler The SqlMapper.TypeHandler<T> implementations

Usage

Register requires an explicit configuration, so the dialect is always a conscious decision:

using AdaskoTheBeAsT.Dapper.NodaTime;
using NodaTime;

DapperNodaTimeSetup.Register(DateTimeZoneProviders.Tzdb, new MyConfiguration());

Provider packages wrap exactly that call, e.g. SqlServerDapperNodaTimeSetup.Register(DateTimeZoneProviders.Tzdb).

Writing values (portable defaults)

NodaTimeTypeHandlerConfigurationBase shapes parameters using only System.Data.DbType:

NodaTime type Parameter value DbType
Instant DateTime (UTC) DateTime2
LocalDate DateTime at midnight, unspecified kind Date
LocalDateTime DateTime, unspecified kind DateTime2
LocalTime TimeSpan since midnight Time
OffsetDateTime DateTimeOffset DateTimeOffset
Offset int seconds Int32
Duration long nanoseconds Int64
Period ISO8601 roundtrip string or DBNull AnsiString
CalendarSystem calendar id string or DBNull AnsiString
DateTimeZone time zone id string or DBNull AnsiString

Reading values

Handlers accept several database representations so the same model works across providers and legacy schemas:

NodaTime type Accepted values
Instant Instant, DateTime, DateTimeOffset, ISO string
LocalDate LocalDate, DateTime, DateOnly (.NET 8+), ISO string
LocalDateTime LocalDateTime, DateTime, ISO string
LocalTime LocalTime, TimeSpan, DateTime, TimeOnly (.NET 8+), ISO string
OffsetDateTime OffsetDateTime, DateTimeOffset, DateTime (treated as UTC), ISO string
Offset Offset, int, long, decimal (seconds)
Duration Duration, long, int, decimal (nanoseconds)
Period Period, ISO8601 roundtrip string
CalendarSystem CalendarSystem, calendar id string
DateTimeZone DateTimeZone, time zone id string

null / DBNull and unsupported CLR types throw System.Data.DataException with a descriptive message. Strings are parsed with CultureInfo.InvariantCulture and DateTimeStyles.RoundtripKind.

Custom dialects

Derive from NodaTimeTypeHandlerConfigurationBase and override only what differs:

using System.Data;
using AdaskoTheBeAsT.Dapper.NodaTime;
using NodaTime;
using NodaTime.Text;

public sealed class InstantAsTextConfiguration : NodaTimeTypeHandlerConfigurationBase
{
    public override void SetInstant(IDbDataParameter parameter, Instant value)
    {
        parameter.Value = InstantPattern.ExtendedIso.Format(value);
        parameter.DbType = DbType.AnsiString;
    }
}

protected static TrySetNative<TParameter>(IDbDataParameter parameter, Action<TParameter> set) applies a provider-specific parameter type only when the parameter really is of that provider type, which keeps the configuration usable with wrappers, profilers and mocks.

Not supported

ZonedDateTime has no handler. Persist LocalDateTime + DateTimeZone (+ CalendarSystem) and compose it in your domain layer.

Target frameworks

net10.0, net9.0, net8.0, netstandard2.1, netstandard2.0, net481, net48, net472, net471, net47, net462.

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 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 is compatible. 
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.
  • .NETFramework 4.6.2

  • .NETFramework 4.7

  • .NETFramework 4.7.1

  • .NETFramework 4.7.2

  • .NETFramework 4.8

  • .NETFramework 4.8.1

  • .NETStandard 2.0

  • .NETStandard 2.1

  • net10.0

  • net8.0

  • net9.0

NuGet packages (6)

Showing the top 5 NuGet packages that depend on AdaskoTheBeAsT.Dapper.NodaTime:

Package Downloads
Mattias1.SqlQueryBuilder.Core

A lightweight querybuilder, using Dapper internally.

AdaskoTheBeAsT.Dapper.NodaTime.SqlServer

SQL Server configuration for AdaskoTheBeAsT.Dapper.NodaTime.

AdaskoTheBeAsT.Dapper.NodaTime.Sqlite

SQLite configuration for AdaskoTheBeAsT.Dapper.NodaTime.

AdaskoTheBeAsT.Dapper.NodaTime.Oracle

Oracle configuration for AdaskoTheBeAsT.Dapper.NodaTime.

AdaskoTheBeAsT.Dapper.NodaTime.PostgreSql

PostgreSQL configuration for AdaskoTheBeAsT.Dapper.NodaTime.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.0 216 7/29/2026
5.0.0 29,844 1/4/2025
4.0.2 8,286 5/27/2024
4.0.0 1,004 11/30/2023
2.0.0 602 7/16/2023
1.0.3 10,336 5/4/2023
1.0.1 15,886 11/20/2022
1.0.0 474 11/20/2022