In ASP.net MVC4 RC's Web-api, I had a Get action defined like before:
public IQueryable<Person> Get()
{
var lst = ctx.GetListFromDB();
return lst.AsQueryable();
}
When it was I was running it before if I called a url like:
/api/people?$inlinecount=allpages&$format=json&$top=50&$filter=(State+eq+'AL'+and+Zip+eq+'35242')
It would do the filtering on the objects, has something changed since the beta that would break this?
You have to put the [Queryable] attribute on the method to allow filtering. The release notes describing the change are here.
Update: In RTM they seem to have separated this feature into its own assembly so you have to include a reference to the ASP.NET Web API OData assembly from Microsoft. You can find the latest version on Nuget https://nuget.org/packages/Microsoft.AspNet.WebApi.OData
Update: In the latest version the Queryable attribute have been renamed to EnableQuery. For more information about changes see http://blogs.msdn.com/b/webdev/archive/2014/03/13/getting-started-with-asp-net-web-api-2-2-for-odata-v4-0.aspx
So, apparently this feature has been removed from the final release schedule. I guess that means we'll need to modify existing WebAPI action methods to include the necessary filtering, sorting, and paging parameters for now. Very sad indeed.
http://aspnetwebstack.codeplex.com/SourceControl/changeset/changes/af11adf6b3c5
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