ZibStack.NET.Dapper 1.7.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZibStack.NET.Dapper --version 1.7.0
                    
NuGet\Install-Package ZibStack.NET.Dapper -Version 1.7.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="ZibStack.NET.Dapper" Version="1.7.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZibStack.NET.Dapper" Version="1.7.0" />
                    
Directory.Packages.props
<PackageReference Include="ZibStack.NET.Dapper">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 ZibStack.NET.Dapper --version 1.7.0
                    
#r "nuget: ZibStack.NET.Dapper, 1.7.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 ZibStack.NET.Dapper@1.7.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=ZibStack.NET.Dapper&version=1.7.0
                    
Install as a Cake Addin
#tool nuget:?package=ZibStack.NET.Dapper&version=1.7.0
                    
Install as a Cake Tool

ZibStack.NET.Dapper

Dapper integration for ZibStack.NET.Dto CRUD API. Provides a DapperCrudStore<TEntity, TKey> base class via source generation.

Install

dotnet add package ZibStack.NET.Dto
dotnet add package ZibStack.NET.Dapper
dotnet add package Dapper

Quick start

  1. Define your entity with [CrudApi]:
[CrudApi]
[CreateDto]
[UpdateDto]
[ResponseDto]
public class Player
{
    [DtoIgnore] public int Id { get; set; }
    public required string Name { get; set; }
    public int Level { get; set; }
}
  1. Implement the store:
using ZibStack.NET.Dapper;

public class PlayerStore : DapperCrudStore<Player, int>
{
    public PlayerStore(IDbConnection db) : base(db) { }
    protected override string TableName => "Players";
}
  1. Register in DI:
builder.Services.AddScoped<IDbConnection>(_ =>
    new SqliteConnection("Data Source=app.db"));
builder.Services.AddScoped<ICrudStore<Player, int>, PlayerStore>();

DapperCrudStore<TEntity, TKey>

Base class implementing ICrudStore<TEntity, TKey> using Dapper:

Method SQL
GetByIdAsync SELECT * FROM {Table} WHERE {Key} = @Id
Query SELECT * FROM {Table} (returns in-memory IQueryable)
CreateAsync INSERT INTO {Table} (columns...) VALUES (@params...)
UpdateAsync UPDATE {Table} SET col = @col, ... WHERE {Key} = @Key
DeleteAsync DELETE FROM {Table} WHERE {Key} = @Key

Configuration

Override virtual properties to customize mapping:

Property Default Description
TableName entity type name + "s" Table name used in SQL
KeyColumn "Id" Primary key column name

Custom queries

All methods are virtual — override any operation for custom SQL:

public class PlayerStore : DapperCrudStore<Player, int>
{
    public PlayerStore(IDbConnection db) : base(db) { }
    protected override string TableName => "Players";

    public override async ValueTask<Player?> GetByIdAsync(int id, CancellationToken ct = default)
    {
        var sql = "SELECT * FROM Players WHERE Id = @Id AND IsDeleted = 0";
        return await SqlMapper.QueryFirstOrDefaultAsync<Player>(Db,
            new CommandDefinition(sql, new { Id = id }, cancellationToken: ct));
    }
}

How it works

This package is a source generator. When your project references both ZibStack.NET.Dto (which provides ICrudStore) and Dapper, the generator emits the DapperCrudStore base class into your compilation. No runtime dependency on this package.

Limitations

  • Query() loads all rows into memory and returns IQueryable over the in-memory collection. For large tables, override Query() with a custom implementation or use filtering at the SQL level.
  • CreateAsync skips the key column (assumes auto-increment). Override for composite keys or non-auto-increment scenarios.
  • Column names are derived from property names via reflection. Override individual methods if your column names differ from property names.
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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
2.7.0 0 4/16/2026
2.6.0 0 4/16/2026
2.5.9 0 4/16/2026
2.5.8 0 4/16/2026
2.5.7 0 4/16/2026
2.5.6 0 4/16/2026
2.5.5 0 4/16/2026
2.5.2 0 4/16/2026
2.5.1 0 4/16/2026
2.5.0 22 4/15/2026
2.4.3 0 4/16/2026
2.4.0 32 4/15/2026
2.3.1 35 4/14/2026
2.3.0 42 4/14/2026
2.2.4 38 4/14/2026
2.2.3 36 4/14/2026
2.2.2 38 4/14/2026
2.2.1 33 4/14/2026
2.2.0 34 4/14/2026
1.7.0 41 4/8/2026
Loading failed