Been playing around with the (Single Page App) BigShelf sample. I found really interesting is the GetBooksForSearch method (/api/BigShelf/GetBooksForSearch) that it takes additional $filter
, $inlinecount
, $top
, $skip
parameters for paging and filtering results, which are not present in the controller code:
public IQueryable<Book> GetBooksForSearch
(string profileIds, Sort sort, bool sortAscending)
I coudln't find any documents about how that Controller translate and filter the result afterwards and more importantly, how to configure such behavior (e.g., limit the max result), anyone have a clue?
-- Updated --
Found out that MVC Web API is doing the trick. But how can we configure it?
It appears that the ResultLimitAttribute has been removed. See this commit
It was rolled into a feature of the [Queryable] attribute which is now required for OData support. See discussion here
Proper Usage would now be
[Queryable(ResultLimit = 10)]
[UPDATE]
As of RTM the ResultLimit feature of Queryable has been removed. Also, [Queryable] has been moved to it's own preview package. See this blog post for more information and this post for instructions on the new usage.
[UPDATE 2 11-16-12] With the ASP.Net Fall 2012 Update Preview things have been updated again. The ResultLimit Property of The [Queryable] attribute has been added back to the OData package.
See article here for a run down of some of the changes.
Here is the updated Nuget package. As of this writing it is a PREVIEW package.
There's an action filter attribute called ResultLimitAttribute
which you can use on any action method which returns IQueryable<T>
or even IEnumerable<T>
to limit the amount of data returned.
[ResultLimit(100)]
public IQueryable<Product> Get() {
// ...
}
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