# Dynamic Query
It's a library that allows you to easily query a queryable using a criteria object.
It also offers, to intercept the query using **IQueryInterceptor** implementations.
## Breaking Changes
If you are moving up from v1, the breaking changes details are lower.
## Getting Started
> Install nuget package to your awesome project.
Full Version | NuGet | NuGet Install
------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------:
PoweredSoft.DynamicQuery | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.DynamicQuery.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.DynamicQuery/) | ```PM> Install-Package PoweredSoft.DynamicQuery```
PoweredSoft.DynamicQuery.Core | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.DynamicQuery.Core.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.DynamicQuery.Core/) | ```PM> Install-Package PoweredSoft.DynamicQuery.Core```
PoweredSoft.DynamicQuery.AspNetCore | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.DynamicQuery.AspNetCore.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.DynamicQuery.AspNetCore/) | ```PM> Install-Package PoweredSoft.DynamicQuery.AspNetCore```
## Using in ASP.NET Core
The package Asp.net core of dynamic query will help you start to use Dynamic Query faster in your web project.
### How to configure during startup
```csharp
using PoweredSoft.DynamicQuery.AspNetCore;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc()
.AddPoweredSoftDynamicQuery();
}
}
```
> How to use in a controller
```csharp
[HttpGet]
public IQueryExecutionResult Get(
[FromServices]YourContext context,
[FromServices]IQueryHandler handler,
[FromServices]IQueryCriteria criteria,
int? page = null,
int? pageSize = null)
{
criteria.Page = page;
criteria.PageSize = pageSize;
IQueryable query = context.Somethings;
var result = handler.Execute(query, criteria);
return result;
}
[HttpPost]
public IQueryExecutionResult Read(
[FromServices]YourContext context,
[FromServices]IQueryHandler handler,
[FromBody]IQueryCriteria criteria)
{
IQueryable query = context.Somethings;
var result = handler.Execute(query, criteria);
return result;
}
```
> New support for async
```csharp
[HttpPost]
public async Task Read(
[FromServices]YourContext context,
[FromServices]IQueryHandlerAsync handler,
[FromBody]IQueryCriteria criteria)
{
IQueryable query = context.Somethings;
var result = await handler.ExecuteAsync(query, criteria);
return result;
}
```
### Sample Web Project - ASP.NET CORE + EF Core
Visit: https://github.com/PoweredSoft/DynamicQueryAspNetCoreSample
### Breaking Changes if you are migrating from 1.x
Response interface, is now generic ```IQueryResult``` which impacts the way to execute the handler.
#### Grouping results
Since the results are now generic, it's no longer a List