ODataQuery class

ODataQuery helps build OData query strings by combining various parameters like $filter, $orderby, $select, and more in a declarative way.

Example:

final query = ODataQuery(
  filter: Filter.and(
    Filter.eq('Name', 'Milk'),
    Filter.lt('Price', 2.55),
  ),
  orderBy: OrderBy.desc('Price'),
  top: 10,
  count: true,
).build();

print(query);
Output: "$filter=Name%20eq%20%27Milk%27%20and%20Price%20lt%202.55&$orderby=Price%20desc&$top=10&$count=true"

Constructors

ODataQuery.new({String? search, Filter? filter, OrderBy? orderBy, List<String>? select, List<String>? expand, int? top, int? skip, bool? count})

Properties

count bool?
The $count parameter determines whether the total count of records should be included in the response. When set to true, the count of the matching entities will be returned along with the result.
final
expand List<String>?
The $expand parameter is used to include related entities in the query response. It allows for expanding related entities, typically in a parent-child relationship.
final
filter Filter?
The $filter parameter is used to apply specific conditions or filters to the query. It helps to narrow down the results by specifying logical operations like eq, ne, lt, gt, etc.
final
hashCode int
The hash code for this object.
no setterinherited
orderBy OrderBy?
The $orderby parameter is used to specify sorting of the results based on one or more fields. You can sort the results in ascending or descending order.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
The $search parameter allows searching for specific values across multiple fields. It supports free-text search, and the search string must be URL-encoded.
final
select List<String>?
The $select parameter allows selecting specific fields to be returned in the result set. This reduces the payload size by fetching only the required properties.
final
skip int?
The $skip parameter is used to skip a specified number of records from the result set. It is useful for implementing pagination alongside $top.
final
top int?
The $top parameter limits the number of records returned by the query. It is useful for pagination or retrieving a fixed number of results.
final

Methods

build() String
Builds the final OData query string by combining all provided options. It constructs a URL-friendly string with encoded values.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited