OData Web API Query Interceptor

1.2k views Asked by At

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.

1

There are 1 answers

2
lencharest On BEST ANSWER

Web API OData does not support query interceptors.