Description
Nuget package Dapper.CX.SqlServer makes it easy to do CRUD operations on pure POCO model classes via IDbConnection extension methods. The only model class requirement is that they have a property called Id or the class has an Identity attribute that indicates what its identity property is. int and long identity types are supported.
Dapper.CX alternatives and similar packages
Based on the "ORM" category.
Alternatively, view Dapper.CX alternatives based on common mentions on social networks and blogs.
-
TypeORM
ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms. -
Dapper
DISCONTINUED. Dapper - a simple object mapper for .Net [Moved to: https://github.com/DapperLib/Dapper] -
Entity Framework
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations. -
SqlSugar
.Net aot ORM Fastest ORM DB2 Hana Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping -
FreeSql
.NET aot orm, VB.NET/C# orm, Mysql/PostgreSQL/SqlServer/Oracle orm, Sqlite/Firebird/Clickhouse/DuckDB orm, 达梦/金仓/虚谷/翰高/高斯 orm, 神通 orm, 南大通用 orm, 国产 orm, TDengine orm, QuestDB orm, MsAccess orm. -
EFCore.BulkExtensions
Entity Framework EF Core efcore Bulk Batch Extensions with BulkCopy in .Net for Insert Update Delete Read (CRUD), Truncate and SaveChanges operations on SQL Server, PostgreSQL, MySQL, SQLite, Oracle -
Dapper Extensions
Dapper Extensions is a small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system. The goal of this library is to keep your POCOs pure by not requiring any attributes or base class inheritance. -
Entity Framework 6
This is the codebase for Entity Framework 6 (previously maintained at https://entityframework.codeplex.com). Entity Framework Core is maintained at https://github.com/dotnet/efcore. -
SmartSql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics -
NPoco
Simple microORM that maps the results of a query onto a POCO object. Project based on Schotime's branch of PetaPoco -
SQLProvider
A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides. -
MongoDB.Entities
A data access library for MongoDB with an elegant api, LINQ support and built-in entity relationship management -
MongoDB Repository pattern implementation
DISCONTINUED. Repository abstraction layer on top of Official MongoDB C# driver -
DbExtensions
Data-access framework with a strong focus on query composition, granularity and code aesthetics. -
NReco.Data
Fast DB-independent DAL for .NET Core: abstract queries, SQL commands builder, schema-less data access, POCO mapping (micro-ORM). -
EntityFrameworkCore.SqlServer.SimpleBulks
Fast and simple bulk insert (retain client populated Ids or return db generated Ids), bulk update, bulk delete, bulk merge and bulk match for SQL Server. -
Linq.Expression.Optimizer
System.Linq.Expression expressions optimizer. http://thorium.github.io/Linq.Expression.Optimizer -
Jerrycurl
DISCONTINUED. Razor-powered ORM for .NET [GET https://api.github.com/repos/rwredding/jerrycurl: 404 - Not Found // See: https://docs.github.com/rest] -
EntityFramework.DatabaseMigrator
EntityFramework.DatabaseMigrator is a WinForms utility to help manage Entity Framework 6.0+ migrations.
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Dapper.CX or a related project?
README
Dapper.CX is a CRUD library for SQL Server made with Dapper. It works with POCO classes, where the only model class requirement is that they have a property called Id
or an Identity attribute on the class that indicates what its identity property is. int
and long
identity types are supported. You can use Dapper.CX in two ways:
- as an injected service, learn more. This is intended for .NET Core apps to use dependency injection along with user profile integration.
- as
IDbConnection
extension methods, learn more. This is simpler to use than the service, but is not as elegant from a dependency standpoint.
Wiki links: Why Dapper.CX?, Reference. Note that Dapper.CX doesn't create tables. Please see my ModelSync project for info on that.
In a Nutshell
When using the injected service, you'd write CRUD code that looks like this. This example assumes a fictional Employee
model class. There are several advantages of using the injected service. One, it integrates nicely with the authenticated user to check permissions or perform audit and change tracking. Two, you can omit the using
block that you otherwise need when interacting with a connection. Three, there are some handy overloads that bundle exception handling and more. Here's how to implement the injected service along with a CRUD method reference.
public Employee ViewRecord { get; set; }
public async Task OnGetAsync(int id)
{
ViewRecord = await Data.GetAsync<Employee>(id);
}
public async Task<IActionResult> OnPostSaveAsync(Employee employee)
{
await Data.SaveAsync(employee);
return Redirect("/Employees");
}
public async Task<IActionResult> OnPostDeleteAsync(int id)
{
await Data.DeleteAsync<Employee>(id);
return Redirect("/Employees");
}
When using the extension methods, it's almost the same thing, but you must open a database connection first. This example assumes a fictional GetConnection
method that opens a SQL Server connection.
public Employee ViewRecord { get; set; }
public async Task OnGetAsync(int id)
{
using (var cn = GetConnection())
{
ViewRecord = await cn.GetAsync<Employee>(id);
}
}
public async Task<IActionResult> OnPostSaveAsync(Employee employee)
{
using (var cn = GetConnection())
{
await cn.SaveAsync(employee);
return Redirect("/Employees");
}
}
public async Task<IActionResult> OnPostDeleteAsync(int id)
{
using (var cn = GetConnection())
{
await cn.DeleteAsync<Employee>(id);
return Redirect("/Employees");
}
}
Customizing behaviors with interfaces
There's a lot of functionality you can opt into by implementing interfaces on your model classes from the AO.Models project. See Extending Dapper.CX with Interfaces. Available interfaces are here.
And one other thing...
In addition to the more common strong-typed CRUD operations, Dapper.CX also offers a SqlCmdDictionary feature that gives you a clean way to build INSERT and UPDATE statements dynamically.
One other thing...
If you need a Dictionary
-like object to persist in a database, you can implement the abstract class DbDictionary. Use this to store any object with a key, using these supported key types. This can save you the effort of adding a single-use dedicated model class for a more generic storage need. Note that, unlike a Dictinoary<TKey, TValue>
, you can use different TValue
s with different keys, so this is very flexible and still type-safe. The abstract methods Serialize and Deserialize let you provide your Json serialization. See the integration test to see in action, along with the sample implementation.
Please see also Dapper.QX, Dapper.CX's companion library.