Guides on consuming ABP's IRepository for provider-neutral data access, including eager loading, tracking, bulk operations, and async LINQ queries.
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.
A repository is ABP's abstraction for querying and persisting an aggregate root, provider-independent — the default generic IRepository is implemented by a data-access provider (EF Core, MongoDB, and the in-memory MemoryDb used in tests; the list isn't fixed). (Dapper is not a default-repository provider: ABP's Dapper integration is a custom DapperRepository layered on EF Core for hand-written SQL — see query-with-dapper.) This skill is about consuming an entity's IRepository<TEntity, TKey> — the method surface, eager loading, provider-neutral querying, tracking, and bulk operations. Defining a custom repository interface and its EF Core/MongoDB implementation is a different task — see ef-core-integration / mongodb-integration.
Final application vs. reusable module — pick before you inject. In a final application you can inject and use the default generic IRepository<TEntity, TKey> directly; that's what this skill shows. In a reusable module you publish for others, follow ABP's module best practice instead: define a custom repository interface per aggregate root in the Domain layer, deriving from IBasicRepository<TEntity, TKey> (not the full IRepository), and keep GetQueryableAsync / IQueryable out of the module's public surface — expose only the query methods the module needs. Define that interface + its provider implementation via ef-core-integration / mongodb-integration. The method surface, eager loading, tracking, and bulk guidance below applies to both.
Inject the repository for your aggregate root; the default is registered automatically:
public class BookManager : IDomainService
{
private readonly IRepository<Book, Guid> _bookRepository;
public BookManager(IRepository<Book, Guid> bookRepository) => _bookRepository = bookRepository;
}
GetAsync, FindAsync, GetListAsync, InsertAsync, …) on an aggregate.WithDetailsAsync (templates don't rely on lazy loading).GetQueryableAsync and executing async without leaking a provider (IAsyncQueryableExecuter).EfCoreRepository<…>, MongoDbRepository<…>, GetDbSetAsync/GetCollectionAsync) — use ef-core-integration / mongodb-integration.AddDefaultRepositories — use layered-architecture.IHasConcurrencyStamp, AbpDbConcurrencyException) — use handle-optimistic-concurrency.| Interface | Gives you | Use when |
|---|---|---|
IRepository<TEntity, TKey> | Full surface: IQueryable access + all reads + writes | The default; the entity has a single primary key. |
IRepository<TEntity> | Same but no id-based methods (GetAsync(id) etc.) | The entity has a composite/no single key. |
IReadOnlyRepository<TEntity, TKey> | Reads + IQueryable, no write methods | A service that must not mutate; on EF Core it also disables change tracking for its results. |
IBasicRepository<TEntity, TKey> | Reads by id/list + writes, no IQueryable | You don't want to depend on LINQ/IQueryable (e.g. a provider without queryable support). |
IReadOnlyBasicRepository<TEntity, TKey> | Basic reads only | Minimal read dependency, no LINQ. |
Prefer the narrowest interface a caller needs. IReadOnlyRepository is not just intent — on EF Core its query results are not change-tracked, which is faster for pure reads.
GetAsync vs FindAsyncBook book = await _bookRepository.GetAsync(id); // throws EntityNotFoundException if missing
Book? maybe = await _bookRepository.FindAsync(id); // returns null if missing
List<Book> all = await _bookRepository.GetListAsync();
long count = await _bookRepository.GetCountAsync();
List<Book> page = await _bookRepository.GetPagedListAsync(skipCount: 0, maxResultCount: 10, sorting: "Name");
GetAsync throws EntityNotFoundException (surfaces as HTTP 404 through ABP) — use it when absence is an error.FindAsync returns null — use it when absence is a normal case you handle.GetAsync(x => x.Name == name), FindAsync(x => …).EnsureExistsAsync(id) / EnsureExistsAsync(predicate) throws EntityNotFoundException when nothing matches — a guard when you only need to assert existence, not load the entity.ABP's startup templates don't enable EF Core lazy loading, so navigations/sub-collections are not auto-loaded — load them explicitly. (You can opt into lazy loading with EF Core's UseLazyLoadingProxies(), but the templates and repository best practices assume explicit/eager loading; ABP doesn't forbid it.) This is the single most common repository gotcha.
GetAsync(id, includeDetails: true) (the default includeDetails is true on the id overloads) loads the entity's default details, defined per-entity by a DefaultWithDetailsFunc in the EF Core repository registration.// default details for the entity
IQueryable<Book> q1 = await _bookRepository.WithDetailsAsync();
// specific navigations only
IQueryable<Book> q2 = await _bookRepository.WithDetailsAsync(b => b.Chapters, b => b.Author);
Only eager-load within the aggregate boundary — a repository loads its own aggregate's sub-entities, not other aggregates. To combine aggregates, query each and join in memory, or use a dedicated read model.
GetQueryableAsync + provider-neutral async executionGetQueryableAsync() returns an IQueryable<TEntity> you can compose with LINQ. The trap: IQueryable's async operators (ToListAsync, FirstOrDefaultAsync, …) are provider-specific — the EF Core ones live in Microsoft.EntityFrameworkCore. Referencing them from Domain/Application code couples those layers to EF Core.
Use ABP's IAsyncQueryableExecuter instead, which resolves to the active provider. In an ApplicationService / DomainService it's the AsyncExecuter property; elsewhere inject IAsyncQueryableExecuter (namespace Volo.Abp.Linq):
var queryable = await _bookRepository.GetQueryableAsync();
var query = queryable.Where(b => b.Price > 100).OrderBy(b => b.Name);
List<Book> list = await AsyncExecuter.ToListAsync(query); // in an app/domain service
Book? first = await AsyncExecuter.FirstOrDefaultAsync(query);
int total = await AsyncExecuter.CountAsync(query);
A queryable must be materialized inside a unit of work (a request scope is one) — the DbContext/session backing it is disposed when the UoW ends. Don't return a raw IQueryable out of that scope. If a caller needs no-tracking and provider-independence, prefer an IReadOnlyRepository or a custom repository method over exposing the queryable.
On EF Core, entities read for update are change-tracked so SaveChanges persists your edits. For read-heavy paths that don't mutate, turn tracking off:
using (_bookRepository.DisableTracking()) { … } (and EnableTracking()) scope a block.[DisableEntityChangeTracking] on a method disables tracking for its duration.IReadOnlyRepository already returns untracked results.Don't disable tracking around code that expects its edits to be saved by the UoW — untracked entities won't be persisted unless you call UpdateAsync explicitly.
await _bookRepository.InsertManyAsync(books, autoSave: true);
await _bookRepository.UpdateManyAsync(books);
await _bookRepository.DeleteManyAsync(books); // or DeleteManyAsync(ids)
await _bookRepository.DeleteDirectAsync(b => b.IsObsolete); // bulk delete by predicate
UpdateManyAsync / DeleteManyAsync handle optimistic concurrency per provider, not uniformly — don't assume bulk means "no ConcurrencyStamp check". MongoDB, for one, re-stamps and re-checks soft-deleted entities and throws an optimistic-concurrency exception when the stamp no longer matches; verify the behavior for the provider you target rather than assuming a concurrent edit goes undetected.
DeleteDirectAsync(predicate) is provider-dependent — the base method is abstract, so there is no shared "bypass" or fallback guarantee:
ExecuteDeleteAsync) and MongoDB (DeleteManyAsync) run a single set-based physical delete that skips the pipeline — no entity loading, no change tracking, no domain/entity events, no concurrency check — and it hard-deletes even ISoftDelete entities (no soft-delete conversion). Efficient for large deletes.DeleteAsync, so soft-delete, events, and auditing do run — the opposite of the set-based providers.So don't treat direct delete as a portable "bypass". On EF Core / MongoDB use it only when the set-based hard delete and skipped side effects are genuinely wanted; otherwise load-and-DeleteAsync so soft-delete, events, and auditing run.
An entity implementing ISoftDelete is not physically removed — DeleteAsync sets IsDeleted = true and ABP's soft-delete data filter hides it from later queries (see apply-data-filters). To remove it permanently, use the HardDeleteAsync repository extension:
await _bookRepository.HardDeleteAsync(b => b.Id == id); // permanent, ignores soft-delete
IQueryable to remote callersIQueryable and repositories are a Domain/Application tool. Never return IQueryable (or expose it via an IQueryable-typed API/OData surface) across a remote/HTTP boundary — materialize inside the UoW and return DTOs or a paged List. Application services return DTOs; repositories return entities; neither returns a live queryable.
WithDetailsAsync(...) or includeDetails: true, and confirm the entity's DefaultWithDetailsFunc covers what you expect.AsyncExecuter) before the scope ends.IReadOnlyRepository / DisableTracking) without an explicit UpdateAsync.WithDetailsAsync / includeDetails: true (or opt into UseLazyLoadingProxies()).ToListAsync/FirstOrDefaultAsync on the queryable — that couples the layer to EF Core; use AsyncExecuter / IAsyncQueryableExecuter.GetAsync where you meant FindAsync — GetAsync throws on missing; FindAsync returns null.DeleteDirectAsync on EF Core / MongoDB for entities that need events/soft-delete/audit — the set-based providers bypass all of them (MemoryDb doesn't — see the provider-dependent note above); load-and-DeleteAsync instead.HardDeleteAsync behavior from DeleteAsync on a soft-delete entity — the latter only flags IsDeleted.IQueryable from an app service / API — materialize to DTOs inside the UoW.https://github.com/abpframework/abp/blob/rel-10.5/docs/en/framework/architecture/domain-driven-design/repositories.mdhttps://github.com/abpframework/abp/blob/rel-10.5/docs/en/framework/architecture/best-practices/repositories.mdWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
abp, irepository, data-access, eager-loading, bulk-operations, dotnet
9 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).
/ef-core-integrationIntegrate Entity Framework Core into an ABP application: AbpDbContext, AddAbpDbContext registration, default/custom repositories, and code-first migrations with DbMigrator. USE FOR: defining an AbpDbContext with ConfigureByConvention, registering it via AddAbpDbContext, wiring AddDefaultRepositories/AddRepository, writing custom EfCoreRepository classes, resolving the active DbContext via IDbContextProvider, adding dotnet ef migrations, running the DbMigrator. DO NOT USE FOR: consuming the standard IRepository method surface — Get/Find/WithDetails/queryable/bulk (use-abp-repositories); MongoDB integration (use mongodb-integration); controlling transaction/UOW boundaries (use manage-units-of-work); soft-delete/multi-tenant/custom query filters (use apply-data-filters); optimistic concurrency stamps (use handle-optimistic-concurrency); Dapper queries (use query-with-dapper); connection-string resolution/config (use configure-connection-strings); seeding data via IDataSeeder (use seed-application-data).
/handle-optimistic-concurrencyEnable and handle ABP optimistic concurrency control so concurrent updates to the same record are detected and rejected. USE FOR: enabling concurrency with IHasConcurrencyStamp/ConcurrencyStamp, deriving from aggregate root base classes to get it for free, flowing the stamp through output and update DTOs, handling AbpDbConcurrencyException when two users update the same record. DO NOT USE FOR: EF-Core-specific mapping/change tracking (use ef-core-integration), MongoDB provider setup (use mongodb-integration), unit-of-work flush/transaction control (use manage-units-of-work), general validation/error surfacing (use handle-validation-and-errors).
/manage-units-of-workControl ABP's Unit of Work — transaction and connection scope, explicit UOW scopes, the [UnitOfWork] attribute, and mid-scope SaveChangesAsync. USE FOR: starting explicit scopes with IUnitOfWorkManager.Begin, applying [UnitOfWork], choosing transactional vs non-transactional boundaries, calling SaveChangesAsync mid-scope, working with nested/RequiresNew/reserved scopes, reading IUnitOfWorkManager.Current, using OnCompleted/CompleteAsync/RollbackAsync. DO NOT USE FOR: defining a DbContext or repositories, or EF Core migrations (use ef-core-integration); MongoDB DbContext/repositories (use mongodb-integration); soft-delete/multi-tenant/custom query filters (use apply-data-filters); optimistic concurrency stamps (use handle-optimistic-concurrency); connection-string resolution (use configure-connection-strings).
/mongodb-integrationIntegrate MongoDB into an ABP application: AbpMongoDbContext, collection mapping, AddMongoDbContext registration, and custom Mongo repositories. USE FOR: defining an AbpMongoDbContext, mapping collections with [MongoCollection]/CreateModel, registering via AddMongoDbContext, wiring AddDefaultRepositories/AddRepository, writing custom MongoDbRepository classes, reaching the DbContext via IMongoDbContextProvider, using GetCollectionAsync/GetAggregateAsync. DO NOT USE FOR: consuming standard IRepository methods (use-abp-repositories); Entity Framework Core integration, DbContext model builder, or code-first migrations (use ef-core-integration); controlling transaction/UOW boundaries (use manage-units-of-work); soft-delete/multi-tenant/custom query filters or MongoDbRepositoryFilterer (use apply-data-filters); optimistic concurrency (use handle-optimistic-concurrency); connection-string configuration (use configure-connection-strings); seeding data via IDataSeeder (use seed-application-data).
/abp-data-access:use-abp-repositoriesfrom abp-data-access
npx claudepluginhub abpframework/abp-skills --plugin abp-data-accessOther plugins' skills for the same job