Skip to main content.


Why Service Query?

API developers typically have to create several API methods to expose their data. For one entity, a developer may have to create several methods such as:

  • Get an entity by a key (such as an integer)
  • Get an entity by a code or name (such as a string)
  • Get a list of entites by a processing flag (such as a boolean value)
  • Get a list of entites by date ranges (such as datetime values)
  • Get a list of entites using multiple criteria (different data types)
  • Get an aggregate value from entities (such as a sum)
  • Get a count and list of entites for paging results
  • And so on...

A small application can have a dozen or more entities, so you may have to create 50 or more methods just to return data.

By implementing Service Query, it eliminates the need to create multiple API methods by exposing a single method per entity that allows access to all your data over a standardized endpoint.

Do You Have Any Examples?

YES! We have created several example API web applications that support several of the most popular database engines.

Visit our GitHub project to download all the examples.

How Does it Work?

Service Query provides a simple object model to serialize complex query instructions over service boundaries. This is done by using a ServiceQueryRequest object that contains a list of filter objects that expose three (3) properties:

  • Properties - List of strings
  • Filter - Enum
  • Values - List of strings

Using our dynamic predicate and expression builders, we transform this simple model into dynamic Linq. This is then executed against the underlying data storage provider using the IQueryable interface. The data storage provider can be a database engine or just a bunch of objects in a list.

Executing the ServiceQueryRequest, it returns back a ServiceQueryResponse object that contains the following properties:

  • List - List<T> of objects - returned for a paged query.
  • Count - int? - returned if including the Count() of records.
  • Aggregate - double? - returned if requesting an aggregate operation.