Production-style REST API with DTOs, Repository Pattern, and Filtering + Sorting + Pagination.
- Data access: Dapper (
Microsoft.Data.SqlClient
) - Error shape: ProblemDetails (RFC 7807)
- Extras: Soft delete, Search, Date-range guardrails
- .NET 9 Web API β Backend framework
- Dapper β Lightweight data access
- SQL Server β Database
- Repository Pattern β Clean architecture & separation of concerns
- DTOs β Safe data transfer between layers
- Dependency Injection β For maintainable, testable code
- OpenAPI β For API exploration and testing
- Thin controllers, repository behind
IBookRepository
- DTOs:
BookCreateDto
,BookUpdateDto
,BookReadDto
,BookFilterDto
- Query params:
search
,minPrice
,maxPrice
,sort
,start
,end
,page
,pageSize
- Sorting:
price_asc|price_desc|title_asc|title_desc|year_asc|year_desc|created_asc|created_desc
- Pagination wrapper:
PagedResult<T>
β{ items, totalCount, page, pageSize }
- Soft delete via
IsArchived
GET /api/books
GET /api/books?search=king&sort=price_desc
GET /api/books?minPrice=10&maxPrice=50
GET /api/books?startDate=2024-01-01&endDate=2024-12-31&page=1&pageSize=10
POST /api/books
PUT /api/books/{id}
DELETE /api/books/{id}
π Getting Started
git clone https://github.com/<your-username>/BooksAPIDapper.git
cd BooksAPIDapper
dotnet restore
dotnet run
# App will print e.g. https://localhost:7205