Skip to main content.

Get Started

Install Service Query into your project using the NuGet instructions on the right.

Service Query supports most SQL and NoSQL database engines or just a bunch of objects in a list! There are 3 core concepts:

Using ServiceQuery in a REST API service:

using ServiceQuery;

[HttpPost]
[Route("ServiceQuery")]
public ServiceQueryResponse<ExampleTable> ServiceQuery(ServiceQueryRequest request)
{
if (request == null)
return null;

var queryable = _context.ExampleTable.AsQueryable();
return request.Execute(queryable);
}

Consuming a ServiceQuery API with JQuery (Front End):

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!

<script src="/js/servicequery.js"></script>
<script type="text/javascript">
function GetAll() {
var request = new ServiceQueryRequestBuilder().Build();
$.ajax({
url: '/api/Example/ServiceQuery',
data: JSON.stringify(request),
type: "POST",
dataType: 'json',
headers: { 'Content-Type': 'application/json' },
success: function (result) {
alert(result.list.length + ' records returned');
}
});
}
</script>

Instructions to Install

Install the NuGet library ServiceQuery NuGet logo

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!

NuGet Package Instructions

Package Manager
Install-Package ServiceQuery -Version 2.0.1
.NET CLI
dotnet add package ServiceQuery --version 2.0.1
Visual Studio
Right-click your project, select Manage NuGet Packages... and install ServiceQuery
Usage

// Get Database Table as IQueryable
var queryable = context.ExampleTable.AsQueryable();

// Build a ServiceQueryRequest
var request = new ServiceQueryRequestBuilder().Build();

// Execute the request
var response = request.Execute(queryable);