问题
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:
Web API OData does not support query interceptors.
来源:https://stackoverflow.com/questions/37061426/odata-web-api-query-interceptor