Oddity
Oddity.Builders.QueryBuilder< TReturn > Class Template Reference

Represents a query builder used to retrieve data with filters specified by the user. More...

Inheritance diagram for Oddity.Builders.QueryBuilder< TReturn >:

Public Member Functions

 QueryBuilder (OddityCore context, CacheService< TReturn > cache, string endpoint)
 Initializes a new instance of the QueryBuilder<TReturn> class. More...
 
QueryBuilder< TReturn > WithFieldEqual< TField > (Expression< Func< TReturn, TField >> selector, TField value)
 Adds an "equal" filter for the specified field. API will return all models with a field value equal to the specified in the parameter. More...
 
QueryBuilder< TReturn > WithFieldGreaterThan< TField > (Expression< Func< TReturn, TField >> selector, TField value)
 Adds a "greater than" filter for the specified field. API will return all models with a field value greater than the specified in the parameter. More...
 
QueryBuilder< TReturn > WithFieldLessThan< TField > (Expression< Func< TReturn, TField >> selector, TField value)
 Adds a "less than" filter for the specified field. API will return all models with a field value less than the specified in the parameter. More...
 
QueryBuilder< TReturn > WithFieldBetween< TField > (Expression< Func< TReturn, TField >> selector, TField from, TField to)
 Adds a "between" filter for the specified field. API will return all models with a field value greater than the bounds specified in the parameters. More...
 
QueryBuilder< TReturn > WithFieldIn< TField > (Expression< Func< TReturn, TField >> selector, params TField[] values)
 Adds an "in" filter for the specified field. API will return all models with a field value containing one of the specified in the parameter. More...
 
QueryBuilder< TReturn > SortBy< TField > (Expression< Func< TReturn, TField >> selector, bool ascending=true)
 Sorts result using the specified field and order (ascending/descending). More...
 
QueryBuilder< TReturn > WithPage (uint page)
 Sets page number which will be returned from API. Don't use this method together with WithOffset (offset will be set to null in this case). More...
 
QueryBuilder< TReturn > WithLimit (uint limit)
 Sets how many elements should be returned from API in the single page. More...
 
QueryBuilder< TReturn > WithOffset (uint offset)
 Sets page number which will be returned from API. Don't use this method together with WithPage (page will be set to null in this case). More...
 
override PaginatedModel< TReturn > Execute ()
 
override bool Execute (PaginatedModel< TReturn > model)
 
override async Task< PaginatedModel< TReturn > > ExecuteAsync ()
 
override async Task< bool > ExecuteAsync (PaginatedModel< TReturn > paginatedModel)
 

Detailed Description

Represents a query builder used to retrieve data with filters specified by the user.

Template Parameters
TReturnType which will be returned after successful API request.
Type Constraints
TReturn :ModelBase 
TReturn :IIdentifiable 
TReturn :new() 

Constructor & Destructor Documentation

Oddity.Builders.QueryBuilder< TReturn >.QueryBuilder ( OddityCore  context,
CacheService< TReturn >  cache,
string  endpoint 
)

Initializes a new instance of the QueryBuilder<TReturn> class.

Parameters
contextThe Oddity context used to interact with API.
cacheCache service used to speed up requests.
endpointThe endpoint used in this instance to retrieve data from API.

Member Function Documentation

override PaginatedModel<TReturn> Oddity.Builders.QueryBuilder< TReturn >.Execute ( )

override bool Oddity.Builders.QueryBuilder< TReturn >.Execute ( PaginatedModel< TReturn >  model)

override async Task<PaginatedModel<TReturn> > Oddity.Builders.QueryBuilder< TReturn >.ExecuteAsync ( )

override async Task<bool> Oddity.Builders.QueryBuilder< TReturn >.ExecuteAsync ( PaginatedModel< TReturn >  paginatedModel)

QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.SortBy< TField > ( Expression< Func< TReturn, TField >>  selector,
bool  ascending = true 
)

Sorts result using the specified field and order (ascending/descending).

Template Parameters
TFieldType of the property (JSON field).
Parameters
selectorProperty (JSON field) selector.
ascendingSort order (ascending/descending).
Returns
Builder instance.
QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.WithFieldBetween< TField > ( Expression< Func< TReturn, TField >>  selector,
TField  from,
TField  to 
)

Adds a "between" filter for the specified field. API will return all models with a field value greater than the bounds specified in the parameters.

Template Parameters
TFieldType of the property (JSON field).
Parameters
selectorProperty (JSON field) selector.
fromLeft bound of the value to match.
toRight bound of the value to match.
Returns
Builder instance.
QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.WithFieldEqual< TField > ( Expression< Func< TReturn, TField >>  selector,
TField  value 
)

Adds an "equal" filter for the specified field. API will return all models with a field value equal to the specified in the parameter.

Template Parameters
TFieldType of the property (JSON field).
Parameters
selectorProperty (JSON field) selector.
valueValue of the field to match.
Returns
Builder instance.
QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.WithFieldGreaterThan< TField > ( Expression< Func< TReturn, TField >>  selector,
TField  value 
)

Adds a "greater than" filter for the specified field. API will return all models with a field value greater than the specified in the parameter.

Template Parameters
TFieldType of the property (JSON field).
Parameters
selectorProperty (JSON field) selector.
valueValue of the field to match.
Returns
Builder instance.
QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.WithFieldIn< TField > ( Expression< Func< TReturn, TField >>  selector,
params TField[]  values 
)

Adds an "in" filter for the specified field. API will return all models with a field value containing one of the specified in the parameter.

Template Parameters
TFieldType of the property (JSON field).
Parameters
selectorProperty (JSON field) selector.
valuesList of values to match.
Returns
Builder instance.
QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.WithFieldLessThan< TField > ( Expression< Func< TReturn, TField >>  selector,
TField  value 
)

Adds a "less than" filter for the specified field. API will return all models with a field value less than the specified in the parameter.

Template Parameters
TFieldType of the property (JSON field).
Parameters
selectorProperty (JSON field) selector.
valueValue of the field to match.
Returns
Builder instance.
QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.WithLimit ( uint  limit)

Sets how many elements should be returned from API in the single page.

Parameters
limitNumber of elements to return.
Returns
Builder instance.
QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.WithOffset ( uint  offset)

Sets page number which will be returned from API. Don't use this method together with WithPage (page will be set to null in this case).

Parameters
offsetNumber of elements to skip.
Returns
Builder instance.
QueryBuilder<TReturn> Oddity.Builders.QueryBuilder< TReturn >.WithPage ( uint  page)

Sets page number which will be returned from API. Don't use this method together with WithOffset (offset will be set to null in this case).

Parameters
pageSelected page number (starting from 1).
Returns
Builder instance.

The documentation for this class was generated from the following file: