TinyHelpers.Dapper 3.2.43

dotnet add package TinyHelpers.Dapper --version 3.2.43
                    
NuGet\Install-Package TinyHelpers.Dapper -Version 3.2.43
                    
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="TinyHelpers.Dapper" Version="3.2.43" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TinyHelpers.Dapper" Version="3.2.43" />
                    
Directory.Packages.props
<PackageReference Include="TinyHelpers.Dapper" />
                    
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 TinyHelpers.Dapper --version 3.2.43
                    
#r "nuget: TinyHelpers.Dapper, 3.2.43"
                    
#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 TinyHelpers.Dapper@3.2.43
                    
#: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=TinyHelpers.Dapper&version=3.2.43
                    
Install as a Cake Addin
#tool nuget:?package=TinyHelpers.Dapper&version=3.2.43
                    
Install as a Cake Tool

Tiny Helpers for Dapper

Lint Code Base CodeQL NuGet NuGet License: MIT

TinyHelpers.Dapper is a small collection of practical Dapper type handlers for .NET applications.

The package helps reduce repetitive mapping code when your database stores values as JSON, delimited strings, or date/time-specific types. Each handler centralizes the conversion contract so queries and repositories do not need custom parsing or serialization logic at every call site.

Compatibility

The package targets:

  • .NET Standard 2.0
  • .NET 8
  • .NET 9
  • .NET 10

Notes:

  • DateOnlyTypeHandler and TimeOnlyTypeHandler are available only on .NET 6+ targets, so they are not compiled for .NET Standard 2.0.
  • JsonTypeHandler<T> can be used with any CLR type that Dapper maps to and from JSON columns.

Installation

Install from NuGet by searching for TinyHelpers.Dapper in Visual Studio Package Manager or using the .NET CLI:

dotnet add package TinyHelpers.Dapper

Contents

Type handlers

JsonTypeHandler<T>

Reads and writes a CLR type as JSON.

Use it when you want to store a value object or small object graph in a single column and keep serializer configuration centralized instead of repeating it in each query or repository. The optional configuration flags let the handler match the JSON contract expected by the database and consuming clients.

StringArrayTypeHandler

Converts string[] values to a single delimited string.

Use it when a database column stores a small set of string values and you want to work with arrays in application code without custom split/join logic. Keep the separator aligned with the stored format so values round-trip reliably.

StringEnumerableTypeHandler

Converts IEnumerable<string> values to a single delimited string.

Use it when you want consuming code to stay sequence-oriented while still persisting a simple delimited representation. Keep the separator aligned with the stored format so query results can reconstruct the sequence correctly.

DateOnlyTypeHandler

Maps DateOnly values to a database date column.

Use it when you want to persist calendar dates without introducing an artificial time component or repeating manual DateTime conversions.

TimeOnlyTypeHandler

Maps TimeOnly values to a database time column.

Use it when you want to persist a time of day without tying it to a calendar date.

TimeSpanTypeHandler

Maps TimeSpan values using ticks.

Use it when you want a stable, culture-independent representation for durations that can be round-tripped across supported target frameworks.

Usage

Register the handlers once at application startup by calling their Configure methods. Dapper type handlers are global, so startup registration keeps conversion behavior consistent for all queries and parameters.

JSON mapping

using System.Text.Json;
using TinyHelpers.Dapper.TypeHandlers;

JsonTypeHandler<Person>.Configure(
    new JsonSerializerOptions(JsonSerializerDefaults.Web),
    useUtcDate: true,
    serializeEnumAsString: true);

String collection mapping

using TinyHelpers.Dapper.TypeHandlers;

StringArrayTypeHandler.Configure(",");
StringEnumerableTypeHandler.Configure(",");

Use the same separator that is already used by the database column format.

Date and time mapping

using TinyHelpers.Dapper.TypeHandlers;

TimeSpanTypeHandler.Configure();

DateOnlyTypeHandler.Configure();
TimeOnlyTypeHandler.Configure();

DateOnlyTypeHandler and TimeOnlyTypeHandler are not available on .NET Standard 2.0.

Quick examples

JSON-backed property mapping

using System.Text.Json;
using TinyHelpers.Dapper.TypeHandlers;

JsonTypeHandler<Metadata>.Configure(
    new JsonSerializerOptions(JsonSerializerDefaults.Web),
    useUtcDate: true,
    serializeEnumAsString: true);

var post = await connection.QuerySingleAsync<Post>(
    "select Id, Metadata from Posts where Id = @Id",
    new { Id = 1 });

String collection mapping

using TinyHelpers.Dapper.TypeHandlers;

StringArrayTypeHandler.Configure(",");

var post = await connection.QuerySingleAsync<Post>(
    "select Id, Tags from Posts where Id = @Id",
    new { Id = 1 });

Date and time mapping

using TinyHelpers.Dapper.TypeHandlers;

DateOnlyTypeHandler.Configure();
TimeOnlyTypeHandler.Configure();
TimeSpanTypeHandler.Configure();

var schedule = await connection.QuerySingleAsync<Schedule>(
    "select StartDate, StartTime, Duration from Schedules where Id = @Id",
    new { Id = 1 });

Contribute

The project is continuously evolving. Contributions, issues, and pull requests are welcome.

Work on the develop branch, not on master. Pull requests should target develop.

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 was computed. 
.NET Framework net461 was computed.  net462 was computed.  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
3.2.43 40 6/18/2026
3.2.40 96 6/10/2026
3.2.37 114 5/22/2026
3.2.36 129 4/15/2026
3.2.34 155 3/11/2026
3.2.33 133 2/11/2026
3.2.31 142 1/14/2026
3.2.30 491 12/10/2025
3.2.29 340 11/13/2025
3.2.27 249 10/15/2025
3.2.25 379 9/10/2025
3.2.23 263 9/1/2025
3.2.21 226 7/30/2025
3.2.20 256 7/9/2025
3.2.18 434 6/11/2025
3.2.17 352 5/14/2025
3.2.16 300 4/9/2025
3.2.15 281 3/18/2025
3.2.14 296 3/12/2025
3.2.13 235 2/28/2025
Loading failed