ASP.net MVC 4 (web api) OData Configuration

前端 未结 4 1575
半阙折子戏
半阙折子戏 2021-01-12 17:23

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

4条回答
  •  被撕碎了的回忆
    2021-01-12 17:58

    There is a short webcast about paging and querying with MVC Web API that you can watch here

    It explains how you can perform paging by either

    • using the OData query syntax, in which case the Web API automatically interprets and retrieves the results for you,
    • or by writing your own method which takes as parameters the pageIndex and pageSize, and then returns the requested number of items.

    AFAIK, you cannot configure the maximum number of items returned by using the first method, but you could limit the number of items returned by using the second approach, and just checking if (pageSize>maxPage) then return maxPage items.

提交回复
热议问题