Table of Contents

Method Retrieve

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

Retrieve(Query)

Executes a query and returns all results in a disconnected result set loaded into memory.

public ResultSet Retrieve(Query query)

Parameters

query Query

The Query to execute.

Returns

ResultSet

A ResultSet containing all query results, disconnected from the database.

Examples

using (var m = new Manager(conn))
{
    var schema = m.LoadSchema("app");
    var usersTable = schema["users"];

    var query = new Query()
        .Select([usersTable["id"], usersTable["name"], usersTable["email"]])
        .From(usersTable)
        .Where(new Criterion<string>(usersTable["role"], ConditionalType.Equals, "admin"));

    // Wrap ResultSet in a using block — caller is responsible for disposal.
    using (ResultSet results = m.Retrieve(query))
    {
        Console.WriteLine($"Found {results.Count} admins");

        // Bind the same result set to two different types in one pass.
        IList<AdminUser> adminUsers = results.BindResults<AdminUser>(BindingType.SnakeCase);
        IList<string> emails = results.BindColumn<string>("email");
    }
}

Remarks

Caller must dispose — always wrap in a using block. The ResultSet holds an in-memory DataTable that must be disposed when you are finished with it.

Advantage over Retrieve<T>(Query, BindingType): multiple bindings. Because the full result set is in memory, you can call BindResults<T>(BindingType) or BindColumn<T>(string) as many times as you like with different types or binding conventions on the same data — something that is not possible with the generic one-shot overload.

Use Retrieve<T>(Query, BindingType) instead when you only need a single binding and want the disposal handled for you automatically.

For large result sets, consider using Search(Query) to stream rows one at a time and avoid loading everything into memory.

Exceptions

DbException

Thrown when a database error occurs.

Retrieve<T>(Query, BindingType)

Executes the query, binds the results to a list of T, and disposes the underlying ResultSet automatically. No using block is required by the caller.

public IList<T> Retrieve<T>(Query query, BindingType bindingType = BindingType.DirectMap) where T : new()

Parameters

query Query

The query to execute.

bindingType BindingType

Controls how column names are mapped to properties. Defaults to DirectMap.

Returns

IList<T>

A fully materialised IList<T> of T.

Type Parameters

T

The type to bind each row to. Must have a parameterless constructor.

Examples

using (Manager manager = new Manager(connection))
{
    // No using block needed — the ResultSet is disposed internally.
    IList<SubscriptionEvent> events = manager.Retrieve<SubscriptionEvent>(query, BindingType.SnakeCase);
}

Remarks

One-shot convenience overload — no disposal needed. This method internally creates a ResultSet, calls BindResults<T>(BindingType) once, disposes the ResultSet, and returns the materialised list. The caller receives a plain IList<T> with no database resources attached.

Single binding only. Because the ResultSet is disposed immediately after the first binding, you cannot bind the same query results to a second type. If you need to bind the same data to multiple types or with different binding conventions, use Retrieve(Query) instead and manage the ResultSet lifetime yourself.