BuildingAnODataAPIAspNetCore
BuildingAnODataAPIAspNetCore copied to clipboard
Question: How to do Imperative handling of ODataQueryOptions in business layer and return IList<T> instead of using [EnableQuery] in Controller
Question 1: How to do ODataQueryOptions imperative style handling instead of Processing query in Action filter [EnableQuery]. We would like to avoid bringing DataContext to Controller at all costs.
Question 2: How to declare controller action method and what will be the route?
myBusinessService.cs
IList<T> ApplyUserFilters(ODataQueryOptions userFilterCriteria)
{
//this includes various filters for Ownership of data based on logged in user
var myQuery = GetQuery();
//apply userFilterCriteria on top
var finalQuery = myQuery.Apply(userFilterCrtieria)
//materialise and return result;
return finalQuery.toList();
}