cqrs-query

Implements CQRS Query and QueryHandler classes for paginated and single-entity reads in .NET microservices.

1|Updated Apr 27, 2026
One-click install
npx skills add https://github.com/GSU26SE55/backend --skill cqrs-query-gsu26se55
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cqrs-query
Source: https://github.com/GSU26SE55/backend/tree/main/.codex/skills/be/cqrs-query
Command: npx skills add https://github.com/GSU26SE55/backend --skill cqrs-query-gsu26se55

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Backend developers repeatedly hand-write CQRS read operations (GetList with pagination, GetById) across microservices, risking inconsistent naming, missed soft-delete filters, and incorrect async handling of IQueryable sources. ## Core Features & Use Cases - Standardized Query Structure: Enforces the Application/Queries/{Entity}Get{Scope} folder layout with matching Query and QueryHandler class naming conventions. - GetList with Pagination: Builds filtered, ordered, paginated queries over IQueryable from GetAllAsync, wrapping results in PaginationResponse with total counts. - GetById with Includes: Loads a single entity with optional navigation properties via Include, returning a not-found response when missing. - Use Case: When adding a new read endpoint for the Battery entity in a .NET 9 microservice, generate the BatteryGetListQuery, its handler with search/status filters, and the BatteryGetByIdQuery handler following the project's exact conventions. ## Quick Start Ask the AI to create a CQRS GetList and GetById query with handlers for a specific entity following the cqrs-query pattern.

Frequently Asked Questions about cqrs-query

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a paginated GetList query in CQRS with .NET?▼

Create a Query class with filter, ordering, PageNumber, and PageSize properties, then in the handler build an IQueryable from GetAllAsync, apply Where filters and ordering, count the total, and use Skip/Take with a Select projection into DTOs wrapped in a PaginationResponse.

How to write a GetById QueryHandler with navigation properties in EF Core?▼

Query GetAllAsync with a Where clause matching the Id and excluding soft-deleted records, chain Include for each needed navigation property, and call FirstOrDefaultAsync. Return a not-found response when the result is null, otherwise map to the DTO inline.

Should I await GetAllAsync when it returns IQueryable?▼

No. In this pattern GetAllAsync is synchronous despite its name and returns IQueryable<T> directly, so awaiting it causes errors. Compose filters and ordering on the IQueryable, then await only the terminal operators like CountAsync, ToListAsync, or FirstOrDefaultAsync.

Why must every query filter IsDeleted in this pattern?▼

The project has no global query filter configured in EF Core, so soft-deleted records would otherwise appear in results. Every handler must explicitly apply .Where(x => !x.IsDeleted) unless an IsDeleted filter parameter overrides it.

Can query handlers call SaveChangesAsync in CQRS?▼

No. Query handlers are read-only operations and must never call SaveChangesAsync. Writes belong exclusively in command handlers, keeping the CQRS separation between read and write paths intact.