I'm trying to enable OData in a Web Api class and am adding the attribute [Queryable] to my query
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
public class ItemsController : ApiController
{
...
[HttpGet]
[Queryable]
public IQueryable<Item> GetItems()
{
return _repository.Items.AsQueryable();
}
but Visual Studio tells me
'Queryable' is not an attribute"
and I get a compilation error:
CS0616: 'System.Linq.Queryable' is not an attribute class
If I qualify the attribute
[System.Web.Http.Queryable]
I get another error message
CS0234: The type or namespace name 'Queryable' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)
Any ideas why the [Queryable] doesn't seem to be recognised? This is a Web forms application to which Web API has been added at a later date.
My bad, it's now in a separate Nuget package
Install-Package Microsoft.AspNet.WebApi.OData -Version 5.3.1
I do wish Microsoft would update their tutorials & docs when they do this kind of thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With