OData过滤器在我的web api中不起作用

时间:2017-06-06 14:00:41

标签: c# asp.net-web-api2 odata

我没有创建OData控制器,而是安装了OData包并将EnableQuery属性添加到IQueryable操作方法。这是我的方法

    [HttpGet]
    [Route("WoundLocations")]
    [EnableQuery]
    public IQueryable<WoundLocation> GetWoundArea()
    {
        return _lookupService.GetWoundLocation().AsQueryable();
    }

我用以下网址调用该操作

  http://dev-xxx.xxxx.com/lookup/WoundLocations?filter=Side eq '0'

返回的结果仍然包含该表中的所有记录。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您在$关键字之前缺少filter,它应该是这样的:

http://dev-xxx.xxxx.com/lookup/WoundLocations?$filter=Side eq '0'