Been playing around with the (Single Page App) BigShelf sample. I found really interesting is the GetBooksForSearch method (/api/BigShelf/GetBooksForSearch) that it takes ad
As Cody Clark pointed out, this area has seen quite a number of changes over time. As of the 5.2 version of WebAPI, you now use the EnableQueryAnnotation
and use the PageSize
parameter rather than QueryableAttribute
or ResultLimit
. ([Queryable]
will still work, but it is marked as obsolete.) Currently you would use the following syntax:
[EnableQuery(PageSize = 20, MaxTop = 20)]
public IQueryable Get() {
// ...
}
By using PageSize
, you set the default page size for unparameterized requests. If you don't include the MaxTop
value, a rogue client could set the top to a very high value and bypass the page defaults. With MaxTop
, you will throw an exception if the client requests more records than your API supports.