Classes

The DynamicWhere.ex library includes the following classes that enable you to construct dynamic queries

Condition

The Condition class represents an individual condition in a dynamic query. It contains the following properties:

  • Sort: An integer that specifies the sort order of the condition.

  • Field: A string that indicates the field or property to which the condition applies.

  • DataType: An instance of the DataType enum, specifying the data type of the condition.

  • Operator: An instance of the Operator enum, defining the logical comparison operator for the condition.

  • Values: A list of strings representing the values to compare against. This list may contain one or more values, depending on the operator.

You can create instances of the Condition class to define individual conditions within your dynamic queries.


ConditionGroup

The ConditionGroup class represents a group of conditions that are logically combined within a dynamic query. It includes the following properties:

  • Sort: An integer that determines the sort order of the condition group.

  • Connector: An instance of the Connector enum, specifying how conditions within the group should be connected (using "AND" or "OR" logic).

  • Conditions: A list of Condition objects representing the conditions within the group.

  • SubConditionGroups: A list of ConditionGroup objects, allowing for nested groups of conditions.

You can use the ConditionGroup class to create complex conditions by combining multiple conditions and nesting groups as needed.


ConditionSet

The ConditionSet class represents a set of conditions in a dynamic query. It includes the following properties:

  • Sort: An integer that defines the sort order of the condition set.

  • Intersection: An instance of the Intersection enum, indicating how conditions within the set should be combined (union, intersection, or exclusion).

  • ConditionGroup: An instance of the ConditionGroup class representing the group of conditions within the set.

You can use the ConditionSet class to create sets of conditions and specify how those conditions should be combined within your dynamic queries.


OrderBy

The OrderBy class is used to configure sorting in dynamic queries. It includes the following properties:

  • Sort: An integer representing the sort order.

  • Field: A string indicating the field or property by which to sort the query results.

  • Direction: An instance of the Direction enum, specifying the sorting direction, which can be either ascending or descending. The default direction is ascending.

You can use the OrderBy class to specify how the query results should be sorted based on the chosen field and sorting direction. It plays a crucial role in customizing the order of your dynamic query results.

By utilizing the OrderBy class in your dynamic queries, you can achieve precise control over the sorting behavior, ensuring that the results are organized according to your requirements.


PageBy

The PageBy class is used to configure pagination settings for dynamic queries. It includes the following properties:

  • PageNumber: An integer representing the desired page number.

  • PageSize: An integer indicating the number of items to display per page.

By utilizing the PageBy class in your dynamic queries, you can control the pagination behavior, specifying which page of results to retrieve and how many items should be displayed on each page. This is essential for managing large sets of data and presenting it to users in a user-friendly manner.


Filter

The Filter class serves as a configuration container for dynamic queries. It encompasses the following components:

  • ConditionGroup (nullable): Represents a condition group that contains a list of conditions and a logical operator. This allows you to create complex queries with multiple conditions. If set to null, it will not affect the query.

  • Select (nullable): Allows you to specify which columns to select from the query result. This feature enhances query performance and resource efficiency by retrieving only the data you need.

  • Orders (nullable): A list of order-by criteria that specify how the query results should be sorted. If set to null, it will not affect the query's sorting.

  • Page (nullable): Pagination settings that determine the page number and the number of items to display per page. If set to null, it will not affect the query's pagination.

By utilizing the Filter class, you can conveniently define conditions, sorting rules, pagination settings, and select specific columns for your dynamic queries. This flexibility allows you to create dynamic queries tailored to your specific requirements, and it accommodates scenarios where you may not need to specify certain filtering, sorting, or pagination criteria, optimizing your query's performance and resource usage.


FilterResult

The FilterResult<T> class is designed to manage the results of filtered queries. It provides information about pagination settings and contains a list of entities of type <T> that match the query conditions.

  • PageNumber: Represents the current page number of the query result.

  • PageSize: Represents the number of entities displayed on each result page.

  • PageCount: Indicates the total number of pages, based on the specified page size and the total entity count.

  • TotalCount: Represents the total count of entities that match the query conditions.

  • Data: Contains the list of entities retrieved as a result of the query.


Segment

The Segment class is the primary container for dynamic queries, offering a structured approach to building complex queries. It features the following key properties:

  • ConditionSets: A list of ConditionSet objects, each representing a set of conditions for filtering data in the query.

  • Select (nullable): Allows you to specify which columns to select from the query result. This feature enhances query performance and resource efficiency by retrieving only the data you need.

  • Orders (nullable): A list of order-by criteria that specify how the query results should be sorted. If set to null, it will not affect the query's sorting.

  • Page (nullable): Pagination settings that determine the page number and the number of items to display per page. If set to null, it will not affect the query's pagination.

The Segment class empowers you to efficiently organize and manage multiple condition sets, apply sorting rules, select specific columns, and implement pagination controls within your dynamic queries. This feature-rich flexibility enhances the precision and performance of your data retrieval operations, allowing you to tailor your queries to meet your specific needs.


SegmentResult

The SegmentResult<T> class is designed to manage the results of segmented queries. It provides information about pagination settings and contains a list of entities of type <T> that match the query conditions.

  • PageNumber: Represents the current page number of the query result.

  • PageSize: Represents the number of entities displayed on each result page.

  • PageCount: Indicates the total number of pages, based on the specified page size and the total entity count.

  • TotalCount: Represents the total count of entities that match the query conditions.

  • Data: Contains the list of entities retrieved as a result of the query.

Last updated