This content is archived. See latest version here

Last updated: Feb 23 2015

Introduction

Similar to LINQ, the EPiServer Find .NET API has methods to

  • Skip-bypass a specified number of search results then return the remaining results.
  • Take-specify the number of search results to return

The Take Method

By default, Find returns 10 search results. Use the Take method to change that value up to a maximum of 1000. If the Take value exceeds 1000 (in other words, Take(1001) or Take(int.MaxValue)), an exception is thrown.

To return more than 1000 results, use multiple search requests.

Examples

Below is an example of using the Skip and Take methods for pagination:

C#
string searchQuery = //From query string or similar
int page = //From query string or similar
int pageSize = 15;

client.Search<BlogPost>()
    .For(searchQuery)
    .Skip((page - 1)*pageSize)
    .Take(pageSize)
    .GetResult();

Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/