Queryable attribute not compiling in mvc 4 web api when trying to mark for odata

I am using MVC 4 web api that comes with visual studio 2012.

As I understand it, odata is not parsed automatically, but we need to add the [Queryable] attribute to the action.

So I added it:

public class TestController : ApiController { [Queryable] public IQueryable<MyClass> GetMyClasses() { return ...; } } 

but I get a compilation error:

 The type or namespace name 'Queryable' could not be found (are you missing a using directive or an assembly reference?) 

Is odata supported? and why the Queryable is not recognized as the attribute specified here.

thanks

+8
c # odata asp.net-mvc asp.net-web-api asp.net-mvc-4
source share
2 answers

As described here , OData support has been ported to a separate NuGet package.

+15
source share

In this assembly (DLL):

  System.Web.Http.OData.dll 

This is the namespace:

 System.Web.Http.QueryableAttribute 

In this package nuget:

 Install-Package Microsoft.AspNet.WebApi.OData 

When I installed the package, it did not appear as a valid type. Even if I verify that System.Web.Http.OData.dll present and viewed in Object Explorer, I could not find it. In the end, I just restarted Visual Studio and everything was fine. I suspect that an older version of this DLL may be misleading or something like that.

+12
source share

All Articles