General Object Retrieval API¶
Advanced search use-cases supported by Backendless include:
- Search with a query (a "where clause" search) -retrieves data objects which satisfy a condition.
- Paged data retrieval - retrieves a "page" of data of the given size from the specified offset.
- Sorted data object retrieval - retrieves a collection of data objects sorted by specified properties.
- Retrieval of related objects - fetching data objects through special "relation" properties. See retrieval of related data objects.
- Calculating aggregate values for a collection of objects - retrieves sum, average, min, max or count for all or a subset of objects in a table. See Aggregate Functions for more details.
Backendless supports the options listed above with a special class - DataQueryBuilder.
The class includes various properties to configure paging and sorting, specify a search query (the where clause
), and/or to request retrieval of objects for specific related properties. The DataQueryBuilder
class provides the following methods:
Argument | Description |
---|---|
Create |
creates a new instance of DataQueryBuilder . |
SetWhereClause |
sets a search query. A query must be in the SQL-92 syntax (the "where" clause part). |
SetSortBy |
sets a collection of column names to sort the data objects in the response by. |
SetRelated |
sets an collection of related columns names. Objects from the related columns are included into the response. For information about relation retrieval, see the Relations (Retrieve) chapter of the documentation. |
SetRelationsDepth |
sets the number of "levels" in the hierarchy of related objects to include into the response. |
SetPageSize |
sets the page size - which is the number of objects to return in the response. Maximum value is 100. For more information on paging, see the Data retrieval with Paging section. |
SetOffset |
sets the offset - an index in the server-side storage from where the data objects should be retrieved. |
SetGroupBy |
Used with Aggregate Functions. Sets the name of a column to group the results by. |
AddGroupBy |
Used with Aggregate Functions. Add the name of the columns to the existing groupBy collection to group the results by. |
SetHavingClause |
Used with Aggregate Functions. Sets a condition on a aggregate function to filter groups. |
Method Signature¶
Blocking API
// Return value from the server is a collection of java.util.Map objects;
IList<Dictionary<string, object>> result;
// The data table must be identified by name. The API
// returns a collection of Dictionary objects.
DataQueryBuilder queryBuilder = DataQueryBuilder.Create();
// set query builder properties to indicate what should be retrieved from the server
queryBuilder..... =
result = Backendless.Data.Of( "TABLE-NAME" ).Find( queryBuilder );
IList<E> result = Backendless.Data.Of<E>().Find( DataQueryBuilder queryBuilder );
Non-Blocking API
Backendless.Data.Of( "TABLE-NAME" ).Find(
DataQueryBuilder query,
AsyncCallback<IList<Dictionary<string, object>>> );
Backendless.Data.Of<E>().Find( DataQueryBuilder queryBuilder,
AsyncCallback<IList<E>> );
where:
Argument | Description |
---|---|
TABLE-NAME |
Name of the table to retrieve data from. |
E |
a .NET class identifying the table to retrieve data from. The name of the class must match the name of the table. |
queryBuilder |
an instance of DataQueryBuilder - contains the search query and other search options. |
responder |
a responder object which will receive a callback when the search operation returns the result. Applies to the non-blocking method only. |
Return Value¶
The blocking method returns a collection of objects found as a result of the query execution. The non-blocking call receives the return value through a callback executed on the AsyncCallback
object.
Examples¶
For examples on using the advanced object retrieval API, see the following sub-sections: