Dapper or an EF Core Page
Whether a query reads its Page in SQL with Dapper or through an EF Core repository, and what each one leaves to you.
What it decides
How a query's handler reads one Page of a list. Both reads take the same PageRequest, the same PageDeclaration of what a caller may sort and filter by, and answer the same Page<T>. They differ in who writes the query: you write the SQL for Dapper, and EF Core translates a repository's expressions.
Dapper runs exactly the SQL you write
No EF Core query filter reaches a Dapper read. A read of a soft-deletable table leaves out removed rows itself, and in a tenant-scoped Module a read of a tenant-scoped table holds it to the tenant itself, in the shape the structure test accepts: Reading. An EF Core Page applies the global query filters for you.
When to choose each
| Dapper | EF Core repository | |
|---|---|---|
| When | A query's read, normally: the Proving Sample's ListProducts reads this way | When a Feature reads its Page through its aggregate's EF Core mapping instead |
| What you write | The SELECT and COUNT once, in a PageSql, with each sort key mapped to a column | A specific repository member on PageAsync, with PageExpressions mapping each declared name |
| Soft delete and tenant | Stated in your SQL | Applied by the global query filters |
| What it reads | What is committed, on a connection of its own | Through the Module's Unit of Work |
Both map the declared names to your own columns or expressions, so no text a caller sends becomes SQL, and both throw before any query runs for a request that never passed validation.
Read a Page
Declare the paging
The query carries a PageRequest, declares its sort keys and filters, and checks the request in its validator: Paging.
Bind it from the query string
An endpoint binds the request with HttpPageRequest: A Page over HTTP.
What the Kit guarantees
| Stated in | |
|---|---|
| The Dapper and EF Core reads of one declaration answer the same Page | Dapper reads, testing |
| A tenant-scoped Module's SQL holds each tenant-scoped table to the tenant | Structure tests |