Last active
May 30, 2019 13:10
-
-
Save mikependon/c39e611a77f0f27c8d58bb5a0b927d4c to your computer and use it in GitHub Desktop.
IDbConnection (BulkInsert<Order>)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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