Run raw SQL via Dapper inside an ABP repository for hot-path read/aggregate queries while sharing ABP's unit of work, connection, and transaction.
Ships in abp-data-access. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
ABP's Volo.Abp.Dapper integration lets you write raw-SQL repositories with Dapper while staying inside ABP's unit of work. The integration is built on top of EF Core: EF Core stays the primary provider and you reach for Dapper only to fine-tune specific queries for maximum performance.
DbContext.DbContext).You mix the two in the same app. The Dapper integration requires an EF Core DbContext — it borrows that context's connection and transaction, so both share the same unit of work.
Run in the folder of the .csproj you want the package in (the database/EF Core layer in a layered solution):
abp add-package Volo.Abp.Dapper
Derive from DapperRepository<TDbContext> (namespace Volo.Abp.Domain.Repositories.Dapper), where TDbContext is your EF Core DbContext. Register it for DI. It implements IUnitOfWorkEnabled, so ABP makes the current connection/transaction available in method bodies via dynamic proxying (interception).
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dapper;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories.Dapper;
using Volo.Abp.EntityFrameworkCore;
public class PersonDapperRepository :
DapperRepository<MyAppDbContext>, ITransientDependency
{
public PersonDapperRepository(IDbContextProvider<MyAppDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public virtual async Task<List<string>> GetAllPersonNamesAsync()
{
var dbConnection = await GetDbConnectionAsync();
return (await dbConnection.QueryAsync<string>(
"select Name from People",
transaction: await GetDbTransactionAsync())
).ToList();
}
public virtual async Task<int> UpdatePersonNameAsync(Guid id, string name)
{
var dbConnection = await GetDbConnectionAsync();
// Always scope a write with a WHERE clause — without it this updates every row.
return await dbConnection.ExecuteAsync(
"update People set Name = @NewName where Id = @Id",
new { Id = id, NewName = name },
await GetDbTransactionAsync());
}
}
The base class hands you the ambient connection and transaction that ABP's unit of work is managing — do not open your own connection:
public virtual async Task<IDbConnection> GetDbConnectionAsync(); // current UoW connection
public virtual async Task<IDbTransaction?> GetDbTransactionAsync(); // current UoW transaction (null if none)
Because these come from the shared IDbContextProvider<TDbContext>:
await GetDbTransactionAsync() to your Dapper calls, so raw SQL participates in the same transaction as EF Core writes — otherwise your Dapper query may not see uncommitted changes and won't roll back with the UoW.[ConnectionStringName]) is inherited from the underlying DbContext, so Dapper hits the same database EF Core would for that context.DbConnection / DbTransaction properties exist but are [Obsolete] — use the async methods.Rules:
virtual. Interception (which supplies the connection/transaction) only works on virtual members.DbContext through IDbContextProvider<TDbContext>, which must be a configured ABP EF Core DbContext (the startup template configures this for you).Define an IPersonDapperRepository interface in the domain layer and implement it in the database/EF Core layer. Inject the interface where you need it, keeping the raw SQL out of the domain and application layers.
abp add-package Volo.Abp.Dapper, confirm the package reference appears in the target .csproj.ChangeTracker — flush them first with autoSave: true on the write or by calling SaveChangesAsync() before the Dapper query.virtual — if interception is missing, GetDbConnectionAsync()/GetDbTransactionAsync() won't resolve the ambient UoW.GetDbConnectionAsync() / GetDbTransactionAsync() from the base class.await GetDbTransactionAsync() to Dapper calls means the raw SQL may not see uncommitted EF Core changes and won't roll back with the UoW.virtual query methods skip interception, so the ambient connection/transaction is never supplied.DbConnection / DbTransaction properties — they are [Obsolete]; use the async methods.framework/data/dapper)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/abp-data-access:query-with-dapperfrom abp-data-access
npx claudepluginhub abpframework/abp-skills --plugin abp-data-access9 skills in this plugin
/apply-data-filtersWork with ABP data filters — the built-in ISoftDelete and IMultiTenant filters, toggling them via IDataFilter scopes, changing default states, and defining custom global query filters for EF Core or MongoDB. USE FOR: reading/writing soft-deleted or cross-tenant data with IDataFilter.Disable/Enable, checking IsEnabled, HardDeleteAsync, changing AbpDataFilterOptions defaults, defining a custom marker-interface filter, wiring it in EF Core (ShouldFilterEntity/CreateFilterExpression/HasAbpQueryFilter) or MongoDB (MongoDbRepositoryFilterer/FilterQueryable). DO NOT USE FOR: switching the active tenant context via ICurrentTenant.Change (that is the multi-tenancy concern); defining a DbContext/repositories or EF Core migrations (use ef-core-integration); MongoDB DbContext/repository setup (use mongodb-integration); transaction/UOW boundaries (use manage-units-of-work); optimistic concurrency (use handle-optimistic-concurrency).
/configure-connection-stringsConfigure ABP connection strings for modular and multi-tenant apps — the Default connection, per-module databases, grouping modules into one database, and per-tenant database routing. USE FOR: setting the Default connection, giving a module its own database with a named entry, binding a DbContext via [ConnectionStringName], mapping several modules to one DB with AbpDbConnectionOptions.Databases, routing a tenant to its own database, customizing IConnectionStringResolver. DO NOT USE FOR: EF Core DbContext registration/model config (use ef-core-integration), MongoDB client/database setup (use mongodb-integration), creating tenants or the tenant store (use configure-multi-tenancy), unit-of-work/transaction handling (use manage-units-of-work).
Other plugins' skills for the same job