Table of Contents

Method AddRecords

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

AddRecords(Table, IEnumerable<Column>, Query)

Inserts multiple records into a table using the results from a query (INSERT INTO ... SELECT pattern).

public void AddRecords(Table table, IEnumerable<Column> columns, Query query)

Parameters

table Table

The Table to insert records into.

columns IEnumerable<Column>

The columns in the target table to populate.

query Query

A Query that returns the data to insert.

Examples

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

    // Create query to select from source
    var query = new Query()
        .Select([sourceTable["name"], sourceTable["email"]])
        .From(sourceTable);

    // Insert results into target table
    var targetColumns = new[] { targetTable["name"], targetTable["email"] };
    m.AddRecords(targetTable, targetColumns, query);
}

Exceptions

DbException

Thrown when a database error occurs.