Skip to content

Instantly share code, notes, and snippets.

@mikependon
Last active May 30, 2019 13:12
Show Gist options
  • Save mikependon/e45ee277217c4b485e32eba4ca0c8777 to your computer and use it in GitHub Desktop.
Save mikependon/e45ee277217c4b485e32eba4ca0c8777 to your computer and use it in GitHub Desktop.
IDbConnection (InsertAll<Orders>)
// Create a 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 InsertAll
using (var connection = new SqlConnection(connectionString))
{
connection.InsertAll<Order>(orders);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment