Table of Contents

Class FindCursor<T, TResult, TSort, TCursor>

Namespace
DataStax.AstraDB.DataApi.Core.Enumeration
Assembly
DataStax.AstraDB.DataApi.dll

A fluent API cursor for finding and enumerating records or rows with filtering, sorting, and projection capabilities.

This cursor extends PaginatedCursor<T, TResult, TOptions, TCursor> to provide query-specific operations like skipping or sorting.

It supports both synchronous and asynchronous iteration patterns.

Use the fluent methods to refine your query, then iterate using foreach, LINQ, or manual cursor navigation.

public abstract class FindCursor<T, TResult, TSort, TCursor> : PaginatedCursor<T, TResult, BaseFindOptions<T, TSort>, TCursor>, IDisposable, IEnumerable<TResult>, IEnumerable, IAsyncEnumerable<TResult> where T : class where TResult : class where TSort : SortBuilder<T> where TCursor : FindCursor<T, TResult, TSort, TCursor>

Type Parameters

T

The type representing the record or row being queried.

TResult

The type to deserialize the results to (e.g., when using projections).

TSort

The type of sort builder to use (e.g., CollectionSortBuilder<T> or TableSortBuilder<T>).

TCursor

The concrete cursor type for fluent method chaining.

Inheritance
PaginatedCursor<T, TResult, BaseFindOptions<T, TSort>, TCursor>
FindCursor<T, TResult, TSort, TCursor>
Implements
IEnumerable<TResult>
Derived
Inherited Members

Methods

IncludeSimilarity(bool)

Specifies whether to include the similarity score in the results.

public TCursor IncludeSimilarity(bool include = true)

Parameters

include bool

Whether to include the similarity score. Defaults to true.

Returns

TCursor

A new cursor instance with the updated setting.

Examples

public class MyDocumentWithSimilarity : MyDocument
{
    [DocumentMapping(DocumentMappingField.Similarity)]
    public double? Similarity { get; set; }
}

var cursor = collection.Find<MyDocumentWithSimilarity>()
    .Sort(Builders<MyDocument>.CollectionSort.Vector(vectorQuery))
    .IncludeSimilarity();

Remarks

Use the DocumentMappingAttribute with Similarity to map the similarity score to a property in your result class.

Skip(int)

Specifies the number of records to skip before starting to return records. Use in conjunction with Sort(TSort) to determine the order before skipping.

public TCursor Skip(int skip)

Parameters

skip int

The number of records to skip.

Returns

TCursor

A new cursor instance with the updated skip value.

Sort(TSort)

Specifies a sort to apply to the query results.

public TCursor Sort(TSort sort)

Parameters

sort TSort

The sort to apply.

Returns

TCursor

A new cursor instance with the updated sort.

Examples

var sort = Builders<MyRecord>.CollectionSort.Ascending(d => d.Name);
var cursor = collection.Find().Sort(sort);