I'm using MVC 4 web api that comes with visual studio 2012.
As I've understand odata is not parsed automatically, but we need to add [Queryable] attribute to the action now.
So I added it:
public class TestController : ApiController
{
[Queryable]
public IQueryable<MyClass> GetMyClasses()
{
return ...;
}
}
but I'm getting a compilation error:
The type or namespace name 'Queryable' could not be found (are you missing a using directive or an assembly reference?)
Is the odata still supported? and why Queryable is not recognized as an attribute as listed here.
Thank you
As explained here, OData support has been moved to a separate NuGet package.
It's in this Assembly (DLL) :
System.Web.Http.OData.dll
This namespace :
System.Web.Http.QueryableAttribute
In this nuget package :
Install-Package Microsoft.AspNet.WebApi.OData
When I installed the package however it didn't appear as a valid type. Even verifying that System.Web.Http.OData.dll
was present and looking in Object Explorer I couldn't find it. Eventually I just restarted Visual Studio and everything was fine. I suspect some older version of this DLL may have been confusing it or something like that.
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