Extensions
The DynamicWhere.ex library includes a set of extension methods that enhance the functionality of LINQ queries for dynamic querying purposes
Where On Condition
Where<T>(this IQueryable<T> query, Condition condition)
This extension method allows you to filter an IQueryable based on a single Condition
.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to filter.condition
(Condition): The single condition specifying the filtering criteria.
Return Value:
IQueryable<T>
: A new queryable instance with the specified condition applied.
Where On Group
Where<T>(this IQueryable<T> query, ConditionGroup group)
This extension method allows you to filter an IQueryable based on a specified ConditionGroup
.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to filter.conditionGroup
(ConditionGroup): The condition group specifying the filtering conditions.
Return Value:
IQueryable<T>
: A new queryable instance with the specified conditions applied.
This extension method empowers you to apply complex filtering on your queries, providing flexibility and precision in your data retrieval.
Specify Select
Select<T>(this IQueryable query, List fields)
This extension method enables you to select specific columns from an IQueryable source based on a list of field names. It provides fine-grained control over the data you retrieve, optimizing query performance and reducing unnecessary data transfer.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to select columns from.fields
(List): A list of field names to include in the query result.
Return Value:
IQueryable<T>
: A new queryable instance with the specified columns selected.
Order By One
Order<T>(this IQueryable<T> query, OrderBy order)
This extension method allows you to order the results of an IQueryable based on a specified OrderBy
configuration.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to order.order
(OrderBy): The order-by configuration specifying the field and sorting direction.
Return Value:
IQueryable<T>
: A new queryable instance with the specified ordering applied.
Order By Many
Order<T>(this IQueryable<T> query, List<OrderBy> orders)
This extension method allows you to order the results of an IQueryable based on a list of OrderBy
configurations.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to order.orders
(List): A list of order-by configurations specifying the fields and sorting directions.
Return Value:
IQueryable<T>
: A new queryable instance with the specified ordering applied.
Pagination
Page<T>(this IQueryable<T> query, PageBy page)
This extension method allows you to apply pagination to an IQueryable, specifying the page number and page size.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to apply pagination to.page
(PageBy): The page object specifying the page number and page size.
Return Value:
IQueryable<T>
: A new queryable instance with pagination applied.
Apply Filter
Filter<T>(this IQueryable<T> query, Filter filter)
This extension method allows you to filter an IQueryable based on a Filter
configuration, including conditions, sorting, and pagination.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to filter.filter
(Filter): The filter configuration specifying conditions, sorting, and pagination.
Return Value:
IQueryable<T>
: A new queryable instance with the specified filtering, ordering, and pagination applied.
Get Filter Result
ToListAsync<T>(this IQueryable<T> query, Filter filter)
This extension method allows you to execute an asynchronous query and retrieve the results as a list based on the specified group of conditions inside filter object.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to execute the dynamic query on.filter
(Filter): The filter object containing group of conditions for dynamic querying. It may also include optional list of order-by criteria and pagination settings.
Return Value:
FilterResult<T>
: An object representing the query results. It includes pagination information (if specified) and a list of entities that match the group of conditions specified in the filter.
Get Segment Result
ToListAsync<T>(this IQueryable<T> query, Segment segment)
This extension method allows you to execute an asynchronous query and retrieve the results as a list based on the specified segment of conditions.
Usage:
Documentation:
Parameters:
query
(IQueryable): The queryable source to execute the dynamic query on.segment
(Segment): The segment object containing sets of conditions for dynamic querying. It may also include optional list of order-by criteria and pagination settings.
Return Value:
SegmentResult<T>
: An object representing the query results. It includes pagination information (if specified) and a list of entities that match the conditions specified in the segment.
Last updated