Take returns a specified number of elements from the beginning of a sequence. In a paged board-game endpoint, it limits the query to the requested page size after Skip calculates the page offset. section 5.4.1
Listing 5.5 BoardGameController.Get() method (with paging)
[HttpGet(Name = "GetBoardGames")]
[ResponseCache(Location = ResponseCacheLocation.Any, Duration = 60)]
public async Task<RestDTO<BoardGame[]>> Get(
int pageIndex = 0,
int pageSize = 10)
{
var query = _context.BoardGames
.Skip(pageIndex * pageSize)
.Take(pageSize);
return new RestDTO<BoardGame[]>()
{
Data = await query.ToArrayAsync(),
PageIndex = pageIndex,
PageSize = pageSize,
RecordCount = await _context.BoardGames.CountAsync(),
Links = new List<LinkDTO> {
new LinkDTO(
Url.Action(
null,
"BoardGames",
new { pageIndex, pageSize },
Request.Scheme)!,
"self",
"GET"),
}
};
}
The controller applies Take(pageSize) after Skip(pageIndex * pageSize), then materializes the selected records asynchronously. section 5.4.1
Paging board games
With pageIndex = 0 and pageSize = 10, Skip removes zero records and Take returns the first ten. Default parameter values keep the endpoint usable when clients omit paging inputs. section 5.4.1



