Linquest Asp.Net Core backend.
Install-Package Linquest.AspNetCore
dotnet add package Linquest.AspNetCore
To add support for linquest queries, you need LinquestActionFilter.
To use callbacks and customizing the request processing;
public class TestController : LinquestController {
public IQueryable<Company> Companies() {
// ...
}
}
public class TestController : ILinquestService {
public IQueryable<Company> Companies() {
// ...
}
// limit the maximum allowed result count, exception will be thrown if given value is exceeded
public int? MaxResultCount { get; set; }
public event BeforeQueryDelegate BeforeHandleQuery;
public event BeforeQueryDelegate BeforeQueryExecute;
public event AfterQueryDelegate AfterQueryExecute;
void ILinquestService.OnBeforeHandleQuery(BeforeQueryEventArgs args)
=> BeforeHandleQuery?.Invoke(this, args);
void ILinquestService.OnBeforeQueryExecute(BeforeQueryEventArgs args)
=> BeforeQueryExecute?.Invoke(this, args);
void ILinquestService.OnAfterQueryExecute(AfterQueryEventArgs args)
=> AfterQueryExecute?.Invoke(this, args);
public ProcessResult ProcessRequest(ActionContext context) {
// you can customize processing the request, or use default processor
return Helper.DefaultRequestProcessor(context, this.HttpContext.RequestServices);
}
}
If you don't need intercepting the Linquest operations, you can use LinquestActionFilter;
[LinquestActionFilter]
public class Test2Controller {
public IQueryable<Company> Companies() {
// ...
}
}
public class Test2Controller {
[LinquestActionFilter]
public IQueryable<Company> Companies() {
// ...
}
}
Linquest handles IQueryable values by default, using QueryableHandler class. You can change handlers by injecting alternative implementations.
public override void ConfigureServices(IServiceCollection services) {
// ...
services.AddSingleton<IContentHandler<IQueryable>, ProductHandler>();
}
public override void ConfigureServices(IServiceCollection services) {
// ...
services.AddSingleton<IContentHandler<PetaPoco.IQuery>, PetaPocoQueryHandler>();
}
// ...
public class PetaPocoQueryHandler: IContentHandler<PetaPoco.IQuery> {
public virtual ProcessResult HandleContent(object query, ActionContext context) {
return HandleContent((PetaPoco.IQuery)query, context);
}
public virtual ProcessResult HandleContent(PetaPoco.IQuery query, ActionContext context) {
// ...
}
}
This way, you can apply linquest query parameters to any type.
Linquest.AspNetCore is under the MIT License.