ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Server
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Download
ScyllaDB Docs ScyllaDB C# driver Features Result paging

Result paging¶

Automatic paging¶

You can iterate indefinitely over the RowSet, having the rows fetched block by block until the rows available on the client side are exhausted.

var ps = session.Prepare("SELECT * from tbl1 WHERE key = ?");
// Set the page size at statement level.
var statement = ps.Bind(key).SetPageSize(1000);
var rs = session.Execute(statement);
foreach (var row in rs)
{
   // The enumerator will yield all the rows from Cassandra.
   // Retrieving them in the back in blocks of 1000.
}

Manual paging¶

If you want to retrieve the next page of results only when you ask for it (for example, in a webpager), use the PagingState property in the RowSet to execute the following statement.

var ps = session.Prepare("SELECT * from tbl1 WHERE key = ?");
// Disable automatic paging.
var statement = ps
   .Bind(key)
   .SetAutoPage(false)
   .SetPageSize(pageSize);
var rs = session.Execute(statement);
// Store the paging state
var pagingState = rs.PagingState;

// Later in time ...
// Retrieve the following page of results.
var statement2 = ps
   .Bind(key)
   .SetAutoPage(false)
   .SetPagingState(pagingState)
var rs2 = Session.Execute(statement2);

Note: The PagingState property is not encrypted and can be used to inject values to retrieve other partitions, so be careful not to expose it to the end user.

Automatic paging in LINQ and Mapper components¶

Both LINQ and Mapper queries support automatic paging: as you iterate through the mapped results, it fetches the following pages. If you want to manually page, you can use Linq’s ExecutePaged() method, Mapper’s FetchPage(), or their async counterparts.

A LINQ paging example:

// Providing page size.
IPage<User> adminUsers = users
   .Where(u => u.Group == "admin")
   .SetPageSize(pageSize)
   .ExecutePaged();


// Providing paging state (following pages).
IPage<User> adminUsers = users
   .Where(u => u.Group == "admin")
   .SetPageSize(pageSize)
   .SetPagingState(pagingState)
   .ExecutePaged();

A Mapper paging example:

IPage<User> users = mapper.FetchPage<User>(pageSize, pagingState, query, parameters);

// Or using query options

IPage<User> authors = mapper.FetchPage<User>(
      Cql.New(query, parameters).WithOptions(opt =>
            opt.SetPageSize(pageSize).SetPagingState(state)));

Was this page helpful?

PREVIOUS
OpenTelemetry
NEXT
Parameterized queries
  • Create an issue
  • Edit this page

On this page

  • Result paging
    • Automatic paging
    • Manual paging
    • Automatic paging in LINQ and Mapper components
ScyllaDB C# driver
  • master
    • master
  • Features
    • Address resolution
    • Authentication and Authorization
    • Automatic failover
    • Column Encryption
    • Driver components
      • ADO.NET
      • Core component
        • Statements
          • Batch statements
          • Per-query keyspace
          • Prepared statements
          • Simple statements
      • Linq component
        • Batch statements with LINQ
      • Mapper component
        • Batch statements with the Mapper
    • Connection heartbeat
    • Connection pooling
    • CQL data types to C# types
      • Date and time representation
      • Nulls and unset
    • Execution Profiles
    • Graph support
    • Cluster and schema metadata
    • Metrics
      • App.Metrics Provider
      • List of metrics
    • Native protocol
    • OpenTelemetry
    • Result paging
    • Parameterized queries
    • Query timestamps
    • Query warnings
    • Request Tracker
    • Routing queries
    • Speculative query execution
    • TLS/SSL
    • Tuning policies
    • User-defined functions and aggregates
    • User-defined types
    • Vector support
  • FAQ
  • Upgrade Guide
  • Examples
  • API Reference
Docs Tutorials University Contact Us About Us
© 2025 ScyllaDB | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 01 Aug 2025.
Powered by Sphinx 7.4.7 & ScyllaDB Theme 1.8.7
Ask AI