# The C# SqlResultSet Class

### For an overview see page C# Classes

## Class Definition

        public class SqlResultSet : IEnumerable<SqlTuple>, IEnumerable, IDisposable
        {
            // Properties
            public string[] ColumnNames { get; }
            public Type[] ColumnTypes { get; }
            public int NumberOfColumns { get; }

            // Methods
            public int GetColumnNo(string column);
            public void Close();
            public void Dispose();
            public IEnumerator<SqlTuple> GetEnumerator();
            IEnumerator IEnumerable.GetEnumerator();

        }

## Member Descriptions

SqlResultSet class
Represents the result of an SQL query execution. Implements enumerable interfaces for iterating through result tuples (`SqlTuple`) and `IDisposable` for resource management.
ColumnNames
Gets an array of column names from the query result. Names are cached after first access for performance.
ColumnTypes
Gets an array of .NET `Type` objects representing the data type of each result column. Uses internal mapping from SQL types to C# types (e.g., tpInt8 → long, tpString → string, tpSequence → Sequence).
NumberOfColumns
Returns the total number of columns in the result set.
GetColumnNo(string)
Finds the zero-based index of a column by its name. Throws `ArgumentException` if the column name is not found in the result set.
Close()
Closes the result set and releases associated resources. Alias for `Dispose()`.
Dispose()
Releases all resources held by the result set: disposes attached cursors, detaches from the parent connection, and closes the native result handle. Implements the `IDisposable` pattern.
GetEnumerator() (generic)
Returns an enumerator for iterating through `SqlTuple` objects. Creates a new `SqlCursor` internally and tracks it for coordinated cleanup.
GetEnumerator() (non-generic)
Explicit interface implementation of `IEnumerable.GetEnumerator()`. Behaves identically to the generic version.
Iteration Pattern
Use `foreach (SqlTuple row in resultSet)` to iterate through results. Each enumeration creates a new cursor; multiple enumerations are independent but share the underlying result data.
Resource Management
Always call `Dispose()` or use a `using` statement to ensure timely release of native resources. The finalizer provides a safety net but should not be relied upon.
Thread Safety
`SqlResultSet` instances are not thread-safe. Access from multiple threads requires external synchronization. Each thread should use its own connection and result set.
Column Access
Use `GetColumnNo()` to resolve column names to indices, then access values via `SqlTuple` indexer: `row[columnIndex]`. Type casting is required based on `ColumnTypes`.