Web Api [Queryable] attribute not recognized

I am trying to enable OData in the Web Api class and adding the [Queryable] attribute 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' (do you miss the assembly reference?)

Any ideas why [Queryable] doesn't seem to be recognized? This is a web form application to which the web interface was added later.

+5
source share
1 answer

My bad, he is now in a separate Nuget package

Installation Package Microsoft.AspNet.WebApi.OData -Version 5.3.1

I would like Microsoft to update its tutorials and documents when they do such things.

+13
source

Source: https://habr.com/ru/post/1212122/


All Articles