Skip to main content

Listing Records

Use SearchAsync to retrieve paginated lists of records from any entity endpoint.

List the first page

Retrieve the first page with the default page size (25):
var endpoint = new CoworkerEndpoint(client);
SearchResult<Coworker> result = await endpoint.SearchAsync();

foreach (var c in result.Records)
    Console.WriteLine($"{c.Id}: {c.FullName}");

Custom page size

Specify a page number and page size:
SearchResult<Coworker> result = await endpoint.SearchAsync(page: 1, size: 10);

Console.WriteLine($"Page {result.CurrentPage} of {result.TotalPages}");
Console.WriteLine($"Showing {result.Records.Count} of {result.TotalItems} records");

Iterate all pages

Loop through every page to process all records:
int page = 1;
int totalPages;

do
{
    var result = await endpoint.SearchAsync(page: page, size: 25);
    totalPages = result.TotalPages;

    foreach (var c in result.Records)
        Console.WriteLine($"{c.Id}: {c.FullName}");

    page++;
} while (page <= totalPages);

SearchResult properties

The SearchResult<T> object returned by SearchAsync provides full pagination metadata:
PropertyTypeDescription
RecordsList<T>The records on the current page.
CurrentPageintThe current page number (1-based).
PageSizeintThe number of records per page.
TotalItemsintTotal number of matching records.
TotalPagesintTotal number of pages available.

Works with any entity

The same pattern applies to every endpoint in the SDK:
var bookings = await new BookingEndpoint(client).SearchAsync();
var products = await new ProductEndpoint(client).SearchAsync();
var businesses = await new BusinessEndpoint(client).SearchAsync();