Skip to content

Instantly share code, notes, and snippets.

@mikependon
Last active May 30, 2019 13:10
Show Gist options
  • Save mikependon/c39e611a77f0f27c8d58bb5a0b927d4c to your computer and use it in GitHub Desktop.
Save mikependon/c39e611a77f0f27c8d58bb5a0b927d4c to your computer and use it in GitHub Desktop.
IDbConnection (BulkInsert<Order>)
// Create the list
var orders = new List<Order>();
// Add each item
orders.Add(new Order { CustomerId = 10045, Quantity = 1, ProductId = 24 });
orders.Add(new Order { CustomerId = 10045, Quantity = 4, ProductId = 27 });
// More orders here
// Call the BulkInsert
using (var connection = new SqlConnection(connectionString))
{
connection.BulkInsert<Order>(orders);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment