Skip to main content.

Basics

Query Building

Before we begin creating queries, there are a few defaults used in the platform. By default:

  • All queries are paged. A query has the following defaults:
    • PageNumber = 1
      PageNumber determines the start page of records to return. Zero or less values will not return any records.
    • PageSize = 1000
      PageSize determines the number of records in a page. Zero or less values will not return any records.
    • IncludeCount = false
      IncludeCount determines if a Count() of the records should also be returned with the query.

Create a New Builder

Creating queries is done by using a builder object that utilizes fluent-style syntax to help create queries.

If you are calling Service Query from a front end with javascript/JQuery, download the servicequery.js file. This javascript file contains a ServiceQueryRequestBuilder class that uses the same syntax as the .NET Framework code!

This can be done by:

Option 1 Standard new object syntax
var builder = new ServiceQueryRequestBuilder();
Option 2 Fluent-style
var builder = ServiceQueryRequestBuilder.New();

Changing Paging Values

Changes values with your ServiceQuery is done by calling the Paging() method. The parameters correspond to the pagenumber, pagesize and includecount properties for the query.

var builder = ServiceQueryRequestBuilder.New().Paging(1, 1000, false); //This is the default

Alternatively, you can set includecount = true by calling the following method IncludeCount()

var builder = ServiceQueryRequestBuilder.New().IncludeCount();

Build the Query into a Request

Once adding filters is complete, build the request by calling the Build() method. This returns a ServiceQueryRequest object with your compiled filters.

var request = ServiceQueryRequestBuilder.New().Build();