asp.netasp.net-web-apiodataasp.net-web-api2queryinterceptor

OData Web API Query Interceptor


OData endpoint is created using ASP.NET Web API 2.0

Trying to create a Query Interceptor in the ODataController like shown in the below code:

public class AVMItemController : ODataController
{
    ADWAppContext sampleADW = new ADWAppContext("Server=XXX;Database=XXX;User ID=XXX;password=xxx;Trusted_Connection=false;Encrypt=true");

    // GET: odata/AVM
    [EnableQuery(PageSize=25)]
    public IQueryable<ADWAppContext.AVMItem> GetAVMItems()
    {
        return sampleADW.AVMItems.AsQueryable<ADWAppContext.AVMItem>();
    }

    [QueryInterceptor("AVMItems")]
    public Expression<Func<ADWAppContext.AVMItem, bool>> FilterAVMItems()
    {
        return avm => avm.avmId > 1000;
    }
}

All the OData queries are processed with out considering the predicate mentioned in Query Interceptor. I have a breakpoint in Query Interceptor Method which never hits.


Solution

  • Web API OData does not support query interceptors.