0
votes

My url is: "/odata/Category?$filter=Number eq 1"

My controller action is this:

[EnableQuery]
public IHttpActionResult Get()
{
    var result = categoryService.GetAll();
    if (result == null)
        return NotFound();

    return Ok(result);
}

GetAll() returns an IQueryable<Category> and that is working because it's returning all records from the db.

However, the OData filter is not filtering out the data. What am I missing?

Furthermore, is the filter applied directly against the db or after all records are returned?

1

1 Answers

0
votes

I have a simple controller that can work.

public class FoosController : ODataController
{
    // GET odata/Foos
     [EnableQuery]
    public IHttpActionResult Get()
    {
        return Ok(FakeData.Instance.Foos.AsQueryable());
    }
}

Please make sure your controller is correct. In your URL, seems that "category" is not in plural form.