Assembly: System.Data (in System.Data.dll)
Gets the SqlBulkCopyColumnMapping object at the specified index.
Creates a new SqlBulkCopyColumnMapping and adds it to the collection, using ordinals to specify both source and destination columns.
Creates a new SqlBulkCopyColumnMapping and adds it to the collection, using an ordinal for the source column and a string for the destination column.
Adds the specified mapping to the.
Creates a new SqlBulkCopyColumnMapping and adds it to the collection, using a column name to describe the source column and an ordinal to specify the destination column.
Creates a new SqlBulkCopyColumnMapping and adds it to the collection, using column names to specify both source and destination columns.
Clears the contents of the collection.
Gets a value indicating whether a specified SqlBulkCopyColumnMapping object exists in the collection.
Copies the elements of the SqlBulkCopyColumnMapping items, starting at a particular index.to an array of
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
Gets the index of the specified SqlBulkCopyColumnMapping object.
Insert a new SqlBulkCopyColumnMapping at the index specified.
Removes the specified SqlBulkCopyColumnMapping element from the .
Removes the mapping at the specified index from the collection.
Returns a string that represents the current object.(Inherited from Object.)
Gets or sets the element at the specified index.(Inherited from CollectionBase.)
Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)
Column mappings define the mapping between data source and the target table.
If mappings are not defined—that is, the ColumnMappings collection is empty—the columns are mapped implicitly based on ordinal position. For this to work, source and target schemas must match. If they do not, an InvalidOperationException is thrown.
If the ColumnMappings collection is not empty, not every column present in the data source has to be specified. Those not mapped by the collection are ignored.
You can refer to source and target columns by either name or ordinal. You can mix by-name and by-ordinal column references in the same mappings collection.
The following example bulk copies data from a source table in the AdventureWorks sample database to a destination table in the same database. Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match. SqlBulkCopyColumnMapping are added to the for the SqlBulkCopy object to create a column map for the bulk copy.
This sample will not run unless you have created the work tables as described in Bulk Copy Example Setup. This code is provided to demonstrate the syntax for using SqlBulkCopy only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL INSERT … SELECT statement to copy the data.
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.