QueryBuilder<T>/OBX_query_builderclass lets you build custom queries for your entities. Create an instance via
enum(C) or a
struct(C++). These provide a way to define query conditions safely, without literal entity and property IDs spread throughout the code. Let's have a look at a fragment of the generated code for a
Userentity (its unique Entity ID is
6and it has three properties:
surname) and the examples below.
buildthe query and finally execute it using
Queryyou should cache the
Queryobject and re-use it. To make a
Querymore reusable you can change the values, or query parameters, of each condition you added even after the
Queryis built. Let's see how.
namevalues. First, we build a regular
name. Because we have to pass an initial parameter value to
equal()but plan to override it before running the
Querylater, we just pass an empty string:
Query. To set a value for the
nameparameter on the
Queryand pass the
nameproperty and the new parameter value:
Alias()right after specifying the condition:
limitmethods to help you do that.
objectbox.hppor API docs to discover more.