Masterly.NonEmptyList.Dapper 3.0.1

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

Masterly.NonEmptyList.Dapper

Dapper type handlers for Masterly.NonEmptyList. Non-empty collections are stored as JSON text columns and NonEmptyString as text; reading an empty or blank column fails instead of producing an empty value.

Installation

dotnet add package Masterly.NonEmptyList.Dapper

Usage

Register once at startup:

using Masterly.NonEmptyList.Dapper;

NonEmptyDapper.AddTypeHandlers<string>();                  // NonEmptyList<string>, ImmutableNonEmptyList<string>, NonEmptySet<string>
NonEmptyDapper.AddDictionaryHandler<string, int>();        // NonEmptyDictionary<string, int>
NonEmptyDapper.AddConstrainedHandler<int, AtLeast<Two>>(); // ConstrainedList<int, AtLeast<Two>>
NonEmptyDapper.AddNonEmptyStringHandler();                 // NonEmptyString and NonEmptyString?
NonEmptyDapper.AddTypeHandlersFor<ProductRow>();           // scans a DTO and registers everything it needs
NonEmptyDapper.AddTypeHandler<OrderLines>();               // any [NonEmptyCollection]-generated class

Then use Dapper as usual:

public sealed class ProductRow
{
    public long Id { get; set; }
    public NonEmptyString Name { get; set; }
    public NonEmptyList<string>? Tags { get; set; }
}

connection.Execute("INSERT INTO Products (Id, Name, Tags) VALUES (@Id, @Name, @Tags)", row);
ProductRow back = connection.QuerySingle<ProductRow>("SELECT * FROM Products WHERE Id = @id", new { id });

Column values are plain JSON (["a","b"]), so they remain queryable with your database's JSON functions. Reading [], whitespace or invalid JSON raises DataException naming the type. Nullable properties read NULL as null.

All registrations are idempotent. Pass JsonSerializerOptions to any Add... method to control element serialization.

Documentation

Full guide: https://a7mdfre7at.github.io/Masterly.NonEmptyList/docs/serialization.

License

MIT

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. 
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.0.1 96 11/2/2026
3.0.0 87 11/2/2026

v3.0.1:
- New package icon: a pair of brackets around a single element

v3.0.0:
- Initial release: NonEmptyDapper.AddTypeHandlers<T>() registers JSON handlers for every non-empty collection of T
- NonEmptyStringTypeHandler for text columns that must have content