Get Paged List Example
Overview
This document demonstrates the complete Get Paged List flow using the GetShippingPagedList feature from the EBusiness application. The flow starts with a GET request to the controller and uses Query projects instead of Handlers in the DomainHandler section for data retrieval. This returns a paginated list of entities with metadata for data grids and large datasets.
Complete Flow Architecture
GET Request → Controller → Service → Query Handler → RESTClient → External System
↓
Response ← Controller ← Service ← Query Handler ← RESTClient ← External SystemDetailed Flow Breakdown
1. GET Request
↓
2. Controller (API Entry Point)
↓
3. Service Layer (Business Orchestration)
↓
4. Query Handler (RESTClient Integration)
├── Internal DTO → Request DTO Mapping
├── RESTClient Call to External System
└── Response DTO → Internal DTO Mapping
↓
5. Response (Paged List with Metadata)Step-by-Step Implementation
1. API Controller - The Entry Point
File: ShippingController_GetShippingPagedList.cs
What Happens:
HTTP Method:
GET /api/Shipping/GetShippingPagedListInput:
GetShippingPagedListParamsfrom query parametersAction: Calls the service layer to process the query
Response: HTTP 200 OK with
FlexiPagedList<GetShippingPagedListDto>
2. Service Layer - Business Orchestration
File: ProcessShippingService_GetShippingPagedList.cs
What Happens:
Query Resolution: Gets the FlexiQuery instance for GetShippingPagedList
Parameter Assignment: Assigns query parameters to the query handler
Query Execution: Calls the Fetch() method to execute the query
Result: Returns paginated list of shipping with metadata
3. Query Handler - RESTClient Integration
File: GetShippingPagedList.cs
What Happens:
Parameter Assignment: Stores query parameters for use in RESTClient calls
Request Mapping: Converts internal parameters to Request DTO
RESTClient Call: Calls external shipping service via RESTClient
Response Mapping: Converts Response DTO to Internal DTO with pagination
Error Handling: Handles success/failure responses from external system
Data Transformation: Applies business logic during mapping
4. Query Parameters - Input DTO
File: GetShippingPagedListParams.cs
What Happens:
Pagination: PageNumber and PageSize for pagination control
Filtering: Multiple filter options for data refinement
Sorting: SortBy and SortDirection for data ordering
Query Parameters: Automatically bound from URL query string
5. Output DTO - Data Transfer Object
File: GetShippingPagedListDto.cs
What Happens:
Grid Data: Contains fields suitable for data grid display
Essential Fields: Includes key information for list views
Performance: Optimized for large dataset display
6. AutoMapper Configuration - Data Transformation
File: GetShippingPagedListMapperConfiguration.cs
What Happens:
Entity to DTO Mapping: Maps domain entities to DTOs
Custom Mappings: Handles complex property transformations
Grid Optimization: Maps fields optimized for data grid display
Key Differences from Get List
Get Paged List vs Get List Characteristics
Return Type
FlexiPagedList<T>
IEnumerable<T>
Pagination
✅ Built-in pagination
❌ No pagination
Use Case
Data grids/tables
Lookup/Dropdown
Performance
Optimized for large datasets
Fast for small datasets
Memory Usage
Higher (includes pagination info)
Lower (no pagination metadata)
Controller Method
RunQueryPagedService
RunQueryListService
Query Base
FlexiQueryPagedListBridge
FlexiQueryEnumerableBridge
Get Paged List-Specific Features
Pagination: Built-in pagination with PageNumber and PageSize
Metadata: Includes total count, page count, and pagination info
Large Datasets: Optimized for handling large amounts of data
Data Grids: Perfect for admin interfaces and data tables
Performance: Efficient memory usage for large datasets
Common Use Cases
Data Grids: Populate data tables with pagination
Admin Interfaces: Large dataset management
Reporting: Paginated report data
Search Results: Paginated search results
Audit Logs: Large audit trail displays
Flow Summary
Synchronous Flow (Data Retrieval)
GET Request → Controller receives request with query parameters
Service Processing → Business orchestration and query resolution
Query Handler → Database query building and execution
AutoMapper → Entity-to-DTO transformation
Pagination → Apply pagination to results
Response → HTTP 200 OK with paginated list and metadata
No Asynchronous Flow
No Events: Query operations don't publish events
No Subscribers: No side effects or event processing
Immediate Response: Data is returned immediately
Query Building Patterns
Basic Query Building
Advanced Query Building with Sorting
Pagination Metadata
FlexiPagedList Structure
Frontend Integration Example
Performance Considerations
Optimization Strategies
Database Indexing: Ensure proper indexes on filter and sort fields
Selective Fields: Only return necessary fields in DTO
Query Optimization: Use efficient WHERE clauses and sorting
Page Size Limits: Set reasonable maximum page sizes
Caching: Consider caching for frequently accessed data
When to Use Get Paged List vs Get List
Data Grids
✅ Yes
❌ No
Large Datasets
✅ Yes
❌ No
Admin Interfaces
✅ Yes
❌ No
Reporting
✅ Yes
❌ No
Dropdown Population
❌ No
✅ Yes
Lookup Tables
❌ No
✅ Yes
Auto-complete
❌ No
✅ Yes
Error Handling
HTTP Status Codes
200 OK: Data retrieved successfully
400 Bad Request: Invalid parameters (invalid page number, page size)
500 Internal Server Error: Database or server error
Parameter Validation
Key Benefits
Performance: Optimized for large datasets with pagination
Memory Efficiency: Only loads required page of data
User Experience: Smooth navigation through large datasets
Metadata: Rich pagination information for frontend
Type Safety: Strongly typed DTOs and parameters
AutoMapper: Automatic entity-to-DTO mapping
No Side Effects: Read-only operations
Testable: Each component can be tested independently
Maintainable: Clear separation of concerns
This GetShippingPagedList example demonstrates how FlexBase enables clean, maintainable, and scalable paginated list operations optimized for data grids and large datasets! 🚀
Last updated