Table of Contents

Method BindColumnAsync

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

BindColumnAsync<T>(string, CancellationToken)

Asynchronous counterpart to BindColumn<T>(string). Binds a single column from query results to a typed async sequence by column name.

public IAsyncEnumerable<T> BindColumnAsync<T>(string columnName, CancellationToken cancellationToken = default)

Parameters

columnName string

The name of the column to bind.

cancellationToken CancellationToken

A token to cancel the underlying ReadAsync calls.

Returns

IAsyncEnumerable<T>

A lazy IAsyncEnumerable<T> that streams typed values from the specified column one row at a time.

Type Parameters

T

The type to bind the column values to.

Examples

await using (ResultReader reader = await manager.SearchAsync(query))
{
    // Extract just the order_total column as decimals
    await foreach (decimal total in reader.BindColumnAsync<decimal>("order_total"))
    {
        Console.WriteLine($"Order total: {total:C}");
    }
}

Remarks

Returns a lazy async sequence backed by yield return. Rows are not fetched until the returned sequence is iterated with await foreach, and each iteration issues a non-blocking ReadAsync(CancellationToken) call against the live database reader. The sequence must be fully consumed inside the enclosing await using (ResultReader ...) block; iterating after the reader has been disposed will throw.

BindColumnAsync<T>(int, CancellationToken)

Asynchronous counterpart to BindColumn<T>(int). Binds a single column from query results to a typed async sequence by column index.

public IAsyncEnumerable<T> BindColumnAsync<T>(int columnIndex, CancellationToken cancellationToken = default)

Parameters

columnIndex int

The zero-based index of the column to bind.

cancellationToken CancellationToken

A token to cancel the underlying ReadAsync calls.

Returns

IAsyncEnumerable<T>

A lazy IAsyncEnumerable<T> that streams typed values from the specified column one row at a time.

Type Parameters

T

The type to bind the column values to.

Remarks

Returns a lazy async sequence backed by yield return. The returned sequence reads from the live database reader and must be iterated inside the enclosing await using (ResultReader ...) block. Iterating after the reader has been disposed will throw.

BindColumnAsync<T>(CancellationToken)

Asynchronous counterpart to BindColumn<T>(). Binds the first column from query results to a typed async sequence.

public IAsyncEnumerable<T> BindColumnAsync<T>(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to cancel the underlying ReadAsync calls.

Returns

IAsyncEnumerable<T>

A lazy IAsyncEnumerable<T> that streams typed values from the first column one row at a time.

Type Parameters

T

The type to bind the column values to.

Remarks

Returns a lazy async sequence backed by yield return. The returned sequence reads from the live database reader and must be iterated inside the enclosing await using (ResultReader ...) block. Iterating after the reader has been disposed will throw.