Skip to content

A clean .NET 9 Web API using Dapper with Repository Pattern, DTOs, filtering, sorting & pagination.

Notifications You must be signed in to change notification settings

edwardgnt/BooksAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Books API (Dapper, .NET 9)

.NET License Dapper Status Build

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

🧰 Tech Stack

  • .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

πŸš€ Features

  • 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

🧭 Example Endpoints

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

About

A clean .NET 9 Web API using Dapper with Repository Pattern, DTOs, filtering, sorting & pagination.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages