Skip to content

Fixes #2054: Support Insert multiple rows from IEnumerable#2086

Merged
jzabroski merged 1 commit into
fluentmigrator:mainfrom
jayharris:issue-2054
Aug 17, 2025
Merged

Fixes #2054: Support Insert multiple rows from IEnumerable#2086
jzabroski merged 1 commit into
fluentmigrator:mainfrom
jayharris:issue-2054

Conversation

@jayharris

@jayharris jayharris commented Jun 19, 2025

Copy link
Copy Markdown
Contributor

For Insert.IntoTable, adds a new Rows method that allows inserting multiple records from a single method call, such as from an instance of IEnumerable<object>. The implementation is done with params for convenient use. Two Rows method were added: for anonymous types and for IDictionary<string, object>, matching the implementation of the existing Row methods.

Rather than using:

foreach (var record in records)
{
    Insert.IntoTable("myTable").Row(record);
}

The code can be simplified to:

Insert.IntoTable("myTable").Rows(records);

Because of params, this also allows developers that are making individual record calls:

Insert.IntoTable("myTable")
    .Row(new { Data1 = "Row1Data1", Data2 = "Row1Data2" })
    .Row(new { Data1 = "Row2Data1", Data2 = "Row2Data2" });

to instead use a single Rows call:

Insert.IntoTable("myTable")
    .Rows(
        new { Data1 = "Row1Data1", Data2 = "Row1Data2" },
        new { Data1 = "Row2Data1", Data2 = "Row2Data2" }
    );

This completes #2054.

Notes:
Regarding the data method argument on the Row method: because data is ambiguous regarding singular and plural use, the argument has been renamed to record/records.

Fixes #2054

@jzabroski jzabroski added this to the 7.2.0 milestone Jun 24, 2025
@jzabroski
jzabroski merged commit a5c5195 into fluentmigrator:main Aug 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support to add multiple rows from an IEnumerable<object>?

2 participants