I've got a regular controller, that has odata capabilities:
[Route("[controller]")]
public class ChannelsController : Controller
{
private readonly ChannelContext db = new ChannelContext();
public IQueryable<PrdChannel> Get()
{
var entities = db.PrdChannel.AsQueryable();
var modelManager = (IODataModelManger) HttpContext.RequestServices.GetService(typeof(IODataModelManger));
var model = modelManager.GetModel(nameof(ProductConfiguration));
var queryContext = new ODataQueryContext(model, typeof(PrdChannel), null);
var queryOptions = new ODataQueryOptions(queryContext, HttpContext.Request);
return queryOptions
.ApplyTo(entities, new ODataQuerySettings
{
HandleNullPropagation = HandleNullPropagationOption.True
})
.Cast<PrdChannel>();
}
}
I am able to issue a GET: https://myservice/Channel?$filter=cable lt 10
However, when I try to do a $select
, it does not work!
https://myservice/Channel?$select=cable
Per the definition of OdataQueryOptions
, it does not support select/expand.
Question: How do we support $select
in aspnetcore?
Perhaps this should be an ODataController?