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

  1. Define/update the stored procedure in src/Sql/dbo/Stored Procedures/ — use plain CREATE PROCEDURE (SSDT syntax)
  2. Create a migration script in util/Migrator/DbScripts/ that deploys it — use CREATE OR ALTER PROCEDURE (idempotent)
  3. Implement the repository method in src/Infrastructure/Dapper/Repositories/ using DapperServiceProvider to call the procedure
  4. 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.

Stored procedure naming convention

Related skills

More from bitwarden/ai-plugins

Installs
47
GitHub Stars
100
First Seen
Feb 13, 2026