AdaskoTheBeAsT.Dapper.NodaTime.SqlServer 6.0.0

dotnet add package AdaskoTheBeAsT.Dapper.NodaTime.SqlServer --version 6.0.0
                    
NuGet\Install-Package AdaskoTheBeAsT.Dapper.NodaTime.SqlServer -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.SqlServer" 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.SqlServer" Version="6.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AdaskoTheBeAsT.Dapper.NodaTime.SqlServer" />
                    
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.SqlServer --version 6.0.0
                    
#r "nuget: AdaskoTheBeAsT.Dapper.NodaTime.SqlServer, 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.SqlServer@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.SqlServer&version=6.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AdaskoTheBeAsT.Dapper.NodaTime.SqlServer&version=6.0.0
                    
Install as a Cake Tool

AdaskoTheBeAsT.Dapper.NodaTime.SqlServer

NuGet

SQL Server dialect for AdaskoTheBeAsT.Dapper.NodaTime. It registers the NodaTime type handlers and shapes every parameter with the matching System.Data.SqlDbType in addition to DbType.

Provider client: Microsoft.Data.SqlClient.

Installation

dotnet add package AdaskoTheBeAsT.Dapper.NodaTime.SqlServer

Usage

using AdaskoTheBeAsT.Dapper.NodaTime.SqlServer;
using NodaTime;

SqlServerDapperNodaTimeSetup.Register(DateTimeZoneProviders.Tzdb);

Call it once during startup. DateTimeZoneProviders.Bcl can be used instead of Tzdb when you need the Windows registry time zone database.

The dialect itself is public as SqlServerNodaTimeConfiguration, so it can be passed to DapperNodaTimeSetup.Register or subclassed.

Parameter mapping

NodaTime type Value written DbType SqlDbType Recommended column
Instant DateTime (UTC) DateTime2 DateTime2 DATETIME2
LocalDate DateTime at midnight Date Date DATE
LocalDateTime DateTime (unspecified) DateTime2 DateTime2 DATETIME2
LocalTime TimeSpan since midnight Time Time TIME
OffsetDateTime DateTimeOffset DateTimeOffset DateTimeOffset DATETIMEOFFSET
Offset int seconds Int32 Int INT
Duration long nanoseconds Int64 BigInt BIGINT
Period ISO8601 roundtrip string AnsiString VarChar VARCHAR(176)
CalendarSystem calendar id AnsiString VarChar VARCHAR(50)
DateTimeZone time zone id AnsiString VarChar VARCHAR(50)

SQL Server is the only supported provider that keeps the original UTC offset of an OffsetDateTime, thanks to DATETIMEOFFSET.

CREATE TABLE Events (
    Id BIGINT PRIMARY KEY,
    CreatedAt DATETIME2 NOT NULL,          -- Instant
    ScheduledAt DATETIME2 NOT NULL,        -- LocalDateTime
    EventDate DATE NOT NULL,               -- LocalDate
    StartTime TIME NOT NULL,               -- LocalTime
    StartsAtWithOffset DATETIMEOFFSET NULL,-- OffsetDateTime
    UtcOffsetSeconds INT NULL,             -- Offset
    RunTimeNanoseconds BIGINT NULL,        -- Duration
    Recurrence VARCHAR(176) NULL,          -- Period
    Calendar VARCHAR(50) NULL,             -- CalendarSystem
    TimeZone VARCHAR(50) NULL);            -- DateTimeZone

Example

using Dapper;
using Microsoft.Data.SqlClient;
using NodaTime;

using var connection = new SqlConnection(connectionString);

await connection.ExecuteAsync(
    "INSERT INTO Events (Id, CreatedAt, ScheduledAt) VALUES (@Id, @CreatedAt, @ScheduledAt)",
    new
    {
        Id = 1L,
        CreatedAt = SystemClock.Instance.GetCurrentInstant(),
        ScheduledAt = new LocalDateTime(2025, 11, 23, 10, 0),
    });

Implementation notes

  • Works with any IDbDataParameter. The native SqlDbType is applied through a cached compiled setter, so wrappers that expose a writable SqlDbType property (for example profiling or retry decorators) are also configured, while parameters without that property simply keep the portable DbType.
  • Both Microsoft.Data.SqlClient and System.Data.SqlClient parameter types are handled by that mechanism.

Target frameworks

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

Product Compatible and additional computed target framework versions.
.NET 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 Framework net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 is compatible. 
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
6.0.0 37 7/29/2026