Skip to content

Api filter#57

Merged
vampi62 merged 5 commits intomainfrom
apiFilter
Feb 26, 2026
Merged

Api filter#57
vampi62 merged 5 commits intomainfrom
apiFilter

Conversation

@vampi62
Copy link
Owner

@vampi62 vampi62 commented Feb 26, 2026

This pull request updates several controller endpoints to support advanced filtering and sorting for paginated GET requests. It introduces RSQL-based filtering and sorting parameters, standardizes paginated responses, and simplifies the handling of total count headers. These changes enhance the flexibility and consistency of the API for clients.

Added support for RSQL-based filtering and sorting via new filter and sort query parameters in the GET endpoints
The controllers now use ParserExtensions.ParseFilter and ParserExtensions.ParseSort to process these parameters.

Updated the return types of relevant GET endpoints to use PaginatedResponseDto<T> instead of a simple IEnumerable<T>, standardizing paginated responses across controllers.

Removed manual setting of X-Total-Count headers and related code from controllers, as the new paginated response DTOs encapsulate pagination metadata.

Add a PaginatedResponseDto (electrostoreAPI/DTO/paginatedReponseDto.cs) and update numerous controllers to return PaginatedResponseDto<T> for list GET endpoints instead of IEnumerable<T>. Removed code that set X-Total-Count headers (pagination info is now returned in the response body). Adjusted related services, interfaces, Program.cs and swagger to match the new paginated response shape.
Introduce RSQL-based filtering and sorting across the API: add filter DTO and ParserExtensions (electrostoreAPI/DTO/filterDto.cs, electrostoreAPI/Extensions/ParserExtensions.cs) and wire ParserExtensions.ParseFilter/ParseSort in controllers. Many controllers now accept optional "filter" and "sort" query parameters (with Swagger descriptions) and pass parsed RSQL/sort DTOs to service methods. Corresponding service method signatures were updated to accept these parsed filter/sort DTOs. This enables standardized client-side filtering and ordering for list endpoints.
Introduce RsqlParserExtensions to convert RSQL-like FilterDto/SorterDto into LINQ expressions for filtering and sorting. inject generated filter expressions, apply dynamic ordering when sort provided, and fall back to sensible default orderings.
Extend RsqlParserExtensions to support nested property access and collection filtering. Update ToFilterExpression usage across many services: destructure the returned tuple into filterResult and rsql, apply the filter to queries, and use null-coalescing predicates for CountAsync/AnyAsync to ensure totals/hasMore respect filters. Add required System.Linq.Expressions imports. Remove multiple controller/service test files and adjust ProgramTests accordingly.
@vampi62 vampi62 merged commit f0461b6 into main Feb 26, 2026
1 check passed
@vampi62 vampi62 deleted the apiFilter branch February 26, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant