SqlServerBulkInsertMapItem
This class extends BulkInsertMapItem to provide a SQL Server-specific type for column mappings, keeping the mapping API consistent with the PostgreSQL and Oracle bulk operations.
Used by the SQL Server BulkInsert, BulkMerge, BulkUpdate and BulkDelete operations.
Create a new Instance
var mapItem = new SqlServerBulkInsertMapItem("SourceId", "DestinationId");
Usage for BulkOperations
var mappings = new []
{
new SqlServerBulkInsertMapItem("FirstName", "FName"),
new SqlServerBulkInsertMapItem("LastName", "LName"),
new SqlServerBulkInsertMapItem("Age", "Age")
};
using (var connection = new SqlConnection(connectionString))
{
var people = GetPeople(100000);
connection.BulkInsert(people, mappings: mappings);
}
The same approach applies to BulkMerge, BulkUpdate and BulkDelete. The
mappingsargument is optional — omitting it causes the library to auto-map columns by name (case-insensitive). The base BulkInsertMapItem class is equally accepted whereverSqlServerBulkInsertMapItemis.