I was working through the following answer found here: Web API OData Inlinecount not working
Here is my controller, with some dummy data being served.
[Queryable]
public class ValuesController : ApiController
{
// GET api/values
public PageResult<Category> Get(ODataQueryOptions<Category> queryOptions)
{
var returnValue = new List<Category>()
{
new Category() { Id = 1, Name= "Category 1"},
new Category() { Id = 2, Name= "Category 2"},
new Category() { Id = 3, Name= "Category 3"},
};
IQueryable results = queryOptions.ApplyTo(returnValue.AsQueryable());
return new PageResult<Category>(results as IEnumerable<Category>,
Request.GetNextPageLink(), Request.GetInlineCount());
}
}
I get the following error when I try to do a get via Fiddler:
"The action 'Get' on controller 'Values' with return type 'System.Web.Http.OData.PageResult`1[[ODataTest_Solution.DTO.Category, ODataTest Solution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' cannot support querying. Ensure the type of the returned content is IEnumerable, IQueryable, or a generic form of either interface."
If I change the method it to return an IQueryable, it obviously works just fine.
Any idea what I might be doing wrong?