OData Web API Query Interceptor

ぃ、小莉子 提交于 2019-12-31 06:59:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!