dapper-repository

Generates Dapper repository methods that call SQL Server stored procedures without inline SQL.

Updated Aug 18, 2026
One-click install
npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill dapper-repository-aurelian1974
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dapper-repository
Source: https://github.com/Aurelian1974/ERPEnterprise/tree/main/.github/skills/dapper-repository
Command: npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill dapper-repository-aurelian1974

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It enforces a strict data-access architecture for ERP systems where C# repositories must never contain inline SQL, ensuring every database call goes through stored procedures, views, or table-valued functions with proper multi-tenant filtering. ## Core Features & Use Cases - Repository Templates: Provides ready-to-use C# templates for INSERT, batch child-table INSERT, GET BY ID, paginated LIST, and UPDATE operations using Dapper's CommandDefinition with CommandType.StoredProcedure. - Paired SQL Scripts: Each C# template ships with a matching CREATE OR ALTER stored procedure script including tenant_id filtering, explicit column lists, and OFFSET/FETCH pagination. - Use Case: When adding a new Invoice entity to an ERP backend, use this Skill to generate the InvoiceRepository class plus usp_CreateInvoice, usp_GetInvoiceById, usp_ListInvoice, and usp_UpdateInvoice procedures that follow the mandatory conventions. ## Quick Start Generate a Dapper repository and its stored procedures for the Customer entity following the zero-inline-SQL rules.

Frequently Asked Questions about dapper-repository

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

FAQPage Schema
How do I write a Dapper repository that calls stored procedures?▼

Inject IDbConnectionFactory and ITenantContext, open the connection with using var conn, then call ExecuteAsync or QueryAsync with a CommandDefinition whose commandType is CommandType.StoredProcedure. Pass parameters as anonymous objects, never via string concatenation.

How to implement paginated list queries with Dapper and SQL Server?▼

Create a stored procedure using COUNT(*) OVER() AS TotalCount with OFFSET and FETCH NEXT for paging, then call it via QueryAsync with TenantId, Search, Page, and PageSize parameters. Read TotalCount from the first row to build the PagedResult.

Can Dapper batch insert child table rows with IEnumerable parameters?▼

Yes, Dapper accepts an IEnumerable of anonymous parameter objects in ExecuteAsync and executes the stored procedure once per item. This works well for child tables with BIGINT IDENTITY keys generated by SQL Server.

Why should C# repositories avoid inline SQL strings?▼

Inline SQL scatters data logic across the codebase, complicates review, and risks SQL injection through string concatenation. Centralizing SQL in stored procedures with CREATE OR ALTER scripts keeps data access versioned, parameterized, and auditable.

How do I enforce multi-tenant filtering in stored procedures?▼

Pass TenantId from ITenantContext as a parameter on every call and include tenant_id = @TenantId in every WHERE clause of the procedure. This applies to SELECT, UPDATE, and DELETE statements alike.