implementing-dapper-queries
Installation
SKILL.md
Repository Pattern
All Dapper implementations live in src/Infrastructure/Dapper/Repositories/. Each repository class implements an interface from src/Core/ and uses stored procedures for all database operations. The repository method is intentionally thin — it maps C# parameters to SQL parameters and maps result sets back to domain objects.
Stored procedures over inline SQL
The default pattern is stored procedures for all Dapper database operations. Some exceptions exist where inline SQL is used — these are provided automatically by the repository base class and parent patterns, not written ad-hoc in individual repository methods.
Workflow
- Define/update the stored procedure in
src/Sql/dbo/Stored Procedures/— use plainCREATE PROCEDURE(SSDT syntax) - Create a migration script in
util/Migrator/DbScripts/that deploys it — useCREATE OR ALTER PROCEDURE(idempotent) - Implement the repository method in
src/Infrastructure/Dapper/Repositories/usingDapperServiceProviderto call the procedure - Write integration tests using
[DatabaseData]attribute
The stored procedure is the source of truth for MSSQL query behavior. The Dapper repository method is thin — it maps parameters and results.