# The C# SqlCursor Class

### For an overview see page C# 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. Valid only after a successful call to `MoveNext()`. Returns `null` if no current tuple exists.
IEnumerator.Current
Explicit interface implementation returning the current tuple as `object`. Behaves identically to the typed `Current` property.
MoveNext()
Advances the cursor to the next tuple in the result set. Returns `true` if a tuple is available, `false` if the end of the result set is reached. Updates the `Current` property on success.
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. Implements the `IDisposable` pattern for use with `using` statements.
Iteration Pattern
Use `foreach (SqlTuple row in resultSet)` for automatic cursor management. For manual iteration: call `MoveNext()` in a loop and access `Current`. Always dispose cursors when done.
Resource Management
Cursors hold native resources. Always call `Dispose()` or use a `using` block to ensure timely cleanup. The `SqlResultSet` tracks attached cursors for coordinated disposal.
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.