Table of Contents

Method BindColumn

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

BindColumn<T>(string)

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

public IEnumerable<T> BindColumn<T>(string columnName)

Parameters

columnName string

The name of the column to bind.

Returns

IEnumerable<T>

An enumerable collection of typed values from the specified column.

Type Parameters

T

The type to bind the column values to.

Examples

var conn = new SqlServerDatasourceConnection
{
    Hostname = "localhost",
    Database = "sales_db",
    Username = "sa",
    Password = "password"
};

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

    var query = new Query()
        .Select([ordersTable["order_total"]])
        .From(ordersTable)
        .Where(new Criterion<DateTime>(ordersTable["order_date"], ConditionalType.GreaterThan, DateTime.Today.AddDays(-30)));

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

BindColumn<T>(int)

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

public IEnumerable<T> BindColumn<T>(int columnIndex)

Parameters

columnIndex int

The zero-based index of the column to bind.

Returns

IEnumerable<T>

An enumerable collection of typed values from the specified column.

Type Parameters

T

The type to bind the column values to.

BindColumn<T>()

Binds the first column from query results to a typed enumerable collection.

public IEnumerable<T> BindColumn<T>()

Returns

IEnumerable<T>

An enumerable collection of typed values from the first column.

Type Parameters

T

The type to bind the column values to.