ZibStack.NET.Dapper
1.7.0
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
<PackageReference Include="ZibStack.NET.Dapper" Version="1.7.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="ZibStack.NET.Dapper" Version="1.7.0" />
<PackageReference Include="ZibStack.NET.Dapper"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add ZibStack.NET.Dapper --version 1.7.0
#r "nuget: ZibStack.NET.Dapper, 1.7.0"
#:package ZibStack.NET.Dapper@1.7.0
#addin nuget:?package=ZibStack.NET.Dapper&version=1.7.0
#tool nuget:?package=ZibStack.NET.Dapper&version=1.7.0
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
- 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; }
}
- Implement the store:
using ZibStack.NET.Dapper;
public class PlayerStore : DapperCrudStore<Player, int>
{
public PlayerStore(IDbConnection db) : base(db) { }
protected override string TableName => "Players";
}
- 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 returnsIQueryableover the in-memory collection. For large tables, overrideQuery()with a custom implementation or use filtering at the SQL level.CreateAsyncskips 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.
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 |