8eb7cd1eec
fix-serialization-contract fix-serialization-contract |
||
---|---|---|
PoweredSoft.DynamicQuery | ||
PoweredSoft.DynamicQuery.AspNetCore | ||
PoweredSoft.DynamicQuery.Cli | ||
PoweredSoft.DynamicQuery.Core | ||
PoweredSoft.DynamicQuery.Test | ||
.gitattributes | ||
.gitignore | ||
DynamicQuery.sln | ||
LICENSE.md | ||
README.md |
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.
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
using PoweredSoft.DynamicQuery.AspNetCore;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc()
.AddPoweredSoftDynamicQuery();
}
}
How to use in a controller
[HttpGet]
public IQueryExecutionResult<OfSomething> Get(
[FromServices]YourContext context,
[FromServices]IQueryHandler handler,
[FromServices]IQueryCriteria criteria,
int? page = null,
int? pageSize = null)
{
criteria.Page = page;
criteria.PageSize = pageSize;
IQueryable<OfSomething> query = context.Somethings;
var result = handler.Execute(query, criteria);
return result;
}
[HttpPost]
public IQueryExecutionResult<OfSomething> Read(
[FromServices]YourContext context,
[FromServices]IQueryHandler handler,
[FromBody]IQueryCriteria criteria)
{
IQueryable<OfSomething> query = context.Somethings;
var result = handler.Execute(query, criteria);
return result;
}
New support for async
[HttpPost]
public async Task<IQueryExecutionResult<OfSomething>> Read(
[FromServices]YourContext context,
[FromServices]IQueryHandlerAsync handler,
[FromBody]IQueryCriteria criteria)
{
IQueryable<OfSomething> 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<T>
which impacts the way to execute the handler.
Grouping results
Since the results are now generic, it's no longer a List