Dapper.MicroCRUD is a small and fast Dapper.Net extension library to perform CRUD statement with POCO models.
- Provide fast and lightweight CRUD extensions for Dapper
- Should be able to run against multiple different databases in the same project
- Thread safety should be guarenteed
I was using the fantastic Dapper.SimpleCRUD library and found it incredibly easy to use. However, two things drove me to write this library - I have a project which uses SqlServer and Postgres databases side-by-side, and unfortunately Dapper.SimpleCRUD does not support this. Second, I found it was missing a few crucial optimizations which was doubling the time taken to easily insert many rows.
Currently, the following DBMS are supported. More will be added (e.g. SQLite) when there is demand for them:
- Microsoft SqlServer 2012 and above
- PostgreSQL
Dapper.MicroCRUD provides the following extensions to the IDbConnection (with Async equivalents):
- Count: Counts how many entities in the table match the conditions.
- Find: Find an entity by it's id, or null.
- Get: Get an entity by it's id, or throw an exception.
- GetRange: Gets all the entities in the table which match the conditions.
- GetPage: Gets a page of entities which match the conditions.
- GetAll: Gets all the entities in the table.
- Insert: Inserts an entity into the table, with the ability to return the generated identity.
- InsertRange: Efficiently inserts multiple entities.
- Update: Updates the entity by using it's primary key.
- UpdateRange: Efficiently updates multiple entities in the database.
- Delete: Deletes an entity
- DeleteRange: Deletes the entities which match the given conditions.
- DeleteAll: Deletes all entities in the table.
Documentation in progress!
Don't forget, for practical examples of usage, you can also browse our extensive unit tests suite.
NB: These may not be correct nor up-to-date. I made this comparison very quickly
Library | Operations | Composite Keys | Async | .Net Core | Notes |
---|---|---|---|---|---|
Dapper.Contrib | Get GetAll Insert Update Delete(All) |
✔️ | ✔️ |
|
|
Dapper.Extensions | Get Insert Update Delete GetList GetPage/GetSet Count |
✔️ |
|
||
Dapper.FastCRUD | Insert Get Find(Equivalent to GetRange) (Bulk)Update (Bulk)Delete Count |
✔️ | ✔️ | ✔️ |
|
Dapper.MicroCRUD | Count Find/Get Get(Range/All) GetPage Insert(Range) Update(Range) Delete(Range/All) |
✔️ | ✔️ |
|
|
Dapper.SimpleCRUD | Get GetList GetListPaged Insert Update Delete(List) RecordCount |
✔️ |
|
Simply add the nuget package Dapper.MicroCRUD to your project.
See License.
This project was written after using Dapper.SimpleCRUD by Eric Coffman, and borrows it's excellent method conventions and API heavily. The code base is however completely rewritten.