Class TableFindCursor<T, TResult>
- Namespace
- DataStax.AstraDB.DataApi.Core.Enumeration
- Assembly
- DataStax.AstraDB.DataApi.dll
A cursor for finding and enumerating rows in a table with projection support. This class allows you to specify a different result type than the row type, useful for projections.
public class TableFindCursor<T, TResult> : FindCursor<T, TResult, TableSortBuilder<T>, TableFindCursor<T, TResult>>, IDisposable, IEnumerable<TResult>, IEnumerable, IAsyncEnumerable<TResult> where T : class where TResult : class
Type Parameters
TThe type of the rows in the table.
TResultThe type to deserialize the results to (e.g., when using projections).
- Inheritance
-
AbstractCursor<TResult>TableFindCursor<T, TResult>
- Implements
-
IEnumerable<TResult>IAsyncEnumerable<TResult>
- Derived
- Inherited Members
Examples
// Using projection to return only specific fields
public class MyRowProjection
{
public string Name { get; set; }
public string Email { get; set; }
}
var cursor = table.Find<MyRowProjection>()
.Project(Builders<MyRow>.Projection
.Include(r => r.Name)
.Include(r => r.Email))
.Limit(100);
var results = await cursor.ToListAsync();
Remarks
This cursor is returned by Find<TResult>(TableFindOptions<T>) and provides a fluent API for filtering, sorting, limiting, and projecting rows into a different result type.
Methods
Clone()
Creates a new cursor instance with the same configuration.
public override TableFindCursor<T, TResult> Clone()
Returns
- TableFindCursor<T, TResult>
A new cursor instance.
CloneWith(Filter<T>, BaseFindOptions<T, TableSortBuilder<T>>)
Creates a new cursor instance with updated filter and options.
protected override TableFindCursor<T, TResult> CloneWith(Filter<T> filter, BaseFindOptions<T, TableSortBuilder<T>> options)
Parameters
filterFilter<T>The filter to apply.
optionsBaseFindOptions<T, TableSortBuilder<T>>The find options to use.
Returns
- TableFindCursor<T, TResult>
A new cursor instance.