The C# SqlCursor Class

SqlCursor is the enumerator used to iterate through the rows of a SqlResultSet. Applications usually obtain a cursor implicitly through foreach, but it can also be used directly for manual row-by-row iteration.

For an overview see page SQL Classes

Class Definition

    public class SqlCursor : IEnumerator<SqlTuple>, IEnumerator, IDisposable
    {
        // ===== PROPERTIES =====
        public SqlTuple Current { get; }
        object IEnumerator.Current { get; }

        // ===== ITERATION METHODS =====
        public bool MoveNext();
        public void Reset();

        // ===== LIFECYCLE METHODS =====
        public void Close();
        public void Dispose();
    }

Member Descriptions

SqlCursor class
Iterator for traversing tuples in an SQL query result (SqlResultSet). Implements standard .NET enumerator interfaces for use with foreach loops and manual iteration.
Current
Gets the current SqlTuple at the cursor position. A meaningful current value is established by a successful call to MoveNext(). Before the first successful move the value is not initialized, and after MoveNext() returns false the last tuple remains available.
IEnumerator.Current
Explicit interface implementation returning the current tuple as object. It exposes the same current tuple as the typed Current property.
MoveNext()
Advances the cursor to the next tuple in the result set. Returns true if a tuple is available and updates Current to that tuple. Returns false when the end of the result set is reached.
Reset()
Resets the cursor to its initial state. Note: This implementation is a no-op as eXtremeDB cursors do not support rewinding. Create a new cursor from the result set to restart iteration.
Close()
Closes the cursor and releases associated native resources. Alias for Dispose().
Dispose()
Releases all resources held by the cursor: detaches from the parent SqlResultSet and closes the native cursor handle. The parent result set can also dispose attached cursors as part of coordinated cleanup.
Iteration Pattern
Use foreach (SqlTuple row in resultSet) for the usual iteration pattern and automatic enumerator disposal. For manual iteration, obtain a cursor from SqlResultSet.GetEnumerator(), call MoveNext() in a loop, and read the current tuple from Current.
Resource Management
Cursors hold native resources. Always call Dispose() or use a using block to ensure timely cleanup. The SqlResultSet tracks attached cursors and closes them when the result set itself is disposed.
Thread Safety
SqlCursor instances are not thread-safe. Do not share a cursor across threads. Each thread should obtain its own cursor from the result set.
Tuple Access
Access column values via the SqlTuple returned by Current. Use SqlResultSet.ColumnNames and ColumnTypes to resolve column indices and perform safe type casting.
Reset Behavior
Reset() is implemented as a no-op in the current C# wrapper. To iterate again from the beginning, create a new cursor by enumerating the parent SqlResultSet again.