Search code examples
asp.net-web-apiodata

web api how to ignore ODataQueryOptions


I have one odata controller without entity framework

[EnableQuery]
public HttpResponseMessage Get(ODataQueryOptions<TicketApp> queryOptions)
{
    List<TicketApp> tList = new List<TicketApp>();
    tList = BL.GetTickets(queryOptions);
    return Request.CreateResponse(HttpStatusCode.OK, new PageResult<TicketApp>(tList, Request.ODataProperties().NextLink, tList.Count()));
}

In my BL.GetTickets I get all filters for to query my DB (without entity) All works, but when my tList returns odata apply query to it and result is empty

How can I return full list without applying odata query? Thanks

For example, if I do this

api/app/ticket?$top=10&$skip=20

BL.GetTickets gets 10 tikets skipping 20, the tList has 10 items

odata skip 20 and get 10 from tList

UPDATE 1

I need to intercepet if clients need to expand items, if I remove EnableQuery complex properties cannot be expanded.


Solution

  • The solution is this:

    Remove [EnableQuery] ad mark with data annotation every complex property with [AutoExpand]