Table of Contents

Class ResultSet

Namespace
YndigoBlue.Velocity.Engine
Assembly
YndigoBlue.Velocity.dll

Provides random-access, reusable result collection loaded entirely into memory.

public class ResultSet : IDisposable, IReadOnlyList<Result>, IReadOnlyCollection<Result>, IEnumerable<Result>, IEnumerable
Inheritance
ResultSet
Implements

Examples

var conn = new SqlServerDatasourceConnection
{
    Hostname = "localhost",
    Database = "mydatabase",
    Username = "sa",
    Password = "MyP@ssw0rd"
};

using (var manager = new Manager(conn))
{
    var schema = manager.LoadSchema("dbo");
    var productsTable = schema["products"];

    var query = new Query()
        .Select([productsTable["id"], productsTable["name"], productsTable["price"], productsTable["category"]])
        .From(productsTable);

    // Use ResultSet for random access and multiple iterations
    ResultSet results = manager.ExecuteResultSet(query);

    // Access by index
    Result firstProduct = results[0];
    Console.WriteLine($"First product: {firstProduct.GetFieldVarChar("name")}");

    // Get total count
    Console.WriteLine($"Total products: {results.Count}");

    // Iterate multiple times
    foreach (Result product in results)
    {
        string name = product.GetFieldVarChar("name");
        decimal price = product.GetFieldDecimal("price");
        Console.WriteLine($"{name}: {price:C}");
    }

    // Filter in memory
    DataRow[] electronics = results.Filter("category = 'Electronics'", "price DESC");
    Console.WriteLine($"Found {electronics.Length} electronics");

    results.Dispose();
}

Remarks

ResultSet is a disconnected, in-memory result processor that loads all query results into a DataTable for random access and multiple iterations. Unlike ResultReader which streams results one at a time, ResultSet loads everything upfront, allowing flexible data access patterns at the cost of memory.

Key Characteristics:

  • Random access - supports indexing and multiple iterations
  • Disconnected - database connection can be closed after loading
  • Loads all results into memory at once
  • Supports in-memory filtering and sorting via DataTable.Select()
  • Ideal for small to medium result sets needing flexible access

When to Use:

  • Need to access results by index or iterate multiple times
  • Need to filter or sort results in memory after retrieval
  • Working with small to medium result sets that fit in memory
  • Need disconnected data access (close connection, keep results)

Use ResultReader instead when:

  • Processing large datasets where memory is a concern
  • Only need sequential, forward-only access
  • Streaming data transformations or exports
  • Results won't be accessed multiple times

Properties

Count

Gets the total number of results in the result set.

DataTable

Gets the underlying DataTable containing all query results.

this[int]

Gets the Result at the specified index.

Methods

BindColumn<T>()

Binds the first column from query results to a typed list.

BindColumn<T>(int)

Binds a single column from query results to a typed list by column index.

BindColumn<T>(string)

Binds a single column from query results to a typed list by column name.

BindResults<T>(BindingType)

Binds query results to a typed list using the specified binding strategy.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Filter(string)

Filters the result set using a DataTable expression without sorting.

Filter(string, string)

Filters the result set using a DataTable expression with sorting.

GetEnumerator()

Returns an enumerator that iterates through the collection.

GetGeoJSON(string, bool)

Converts query results containing geospatial data to GeoJSON format.