Search code examples
c#asp.net-web-api2odata

OData filter is not working in my web api


I didn't create OData controller, instead, I just installed OData package and add EnableQuery attribute to the IQueryable action method. Here is my method

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

And I call the action with the following url

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

The returned result still has all the records in that table. Any thoughts?


Solution

  • You are missing a $ before the filter keyword, it should be like this:

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