OracleBulkCopyColumnMappingCollection Class

The OracleBulkCopyColumnMappingCollection class represents a collection of OracleBulkCopyColumnMapping objects that are used to map columns in the data source to columns in a destination table.

Class Inheritance

System.Object

  System.CollectionBase

    System.OracleBulkCopyColumnMappingCollection

Declaration

// C#
public sealed class OracleBulkCopyColumnMappingCollection : CollectionBase

Requirements

Provider ODP.NET, Unmanaged Driver
Assembly Oracle.DataAccess.dll
Namespace Oracle.DataAccess.Client
.NET Framework 3.5, 4.0, 4.5

Thread Safety

All public static methods are thread-safe, although instance methods do not guarantee thread safety.

Remarks

Column mappings define the mapping between data source and the target table.

It is not necessary to specify column mappings for all the columns in the data source. If a ColumnMapping is not specified, then, by default, columns are mapped based on the ordinal position. This succeeds only if the source and destination table schema match. If there is a mismatch, an InvalidOperationException is thrown.

All the mappings in a mapping collection must be by name or ordinal position.

Note:

Oracle Data Provider for .NET makes one or more round-trips to the database to determine the column name if the mapping is specified by ordinal position. To avoid this performance overhead, specify the mapping by column name.

Example

// C#

OracleBulkCopyColumnMappingCollection Members

OracleBulkCopyColumnMappingCollection members are listed in the following tables.

OracleBulkCopyColumnMappingCollection Properties

The OracleBulkCopyColumnMappingCollection properties are listed in Table 17-13.

Table 17-13 OracleBulkCopyColumnMappingCollection Properties

Property Description

Item[index]

Gets or sets the OracleBulkCopyColumnMappingCollection object at the specified index


OracleBulkCopyColumnMappingCollection Public Methods

The OracleBulkCopyColumnMappingCollection public methods are listed in Table 17-14.

Table 17-14 OracleBulkCopyColumnMappingCollection Public Methods

Public Method Description

Add

Adds objects to the collection

Clear

Clears the contents of the collection

Contains

Returns a value indicating whether or not a specified OracleBulkCopyColumnMapping object exists in the collection

CopyTo

Copies the elements of the OracleBulkCopyColumnMappingCollection to an array of OracleBulkCopyColumnMapping items, starting at a specified index

IndexOf

Returns the index of the specified OracleBulkCopyColumnMapping object

Insert

Inserts a new OracleBulkCopyColumnMapping object in the collection, at the index specified.

Remove

Removes the specified OracleBulkCopyColumnMapping element from the OracleBulkCopyColumnMappingCollection.

RemoveAt

Removes the mapping from the collection at the specified index.


OracleBulkCopyColumnMappingCollection Properties

The OracleBulkCopyColumnMappingCollection properties are listed in Table 17-15.

Table 17-15 OracleBulkCopyColumnMappingCollection Properties

Property Description

Item[index]

Gets or sets the OracleBulkCopyColumnMappingCollection object at the specified index


Item[index]

This property gets or sets the OracleBulkCopyColumnMapping object at the specified index.

Declaration

// C#
public OracleBulkCopyColumnMapping this[int index] {get;set;}

Parameters

  • index

    The zero-based index of the OracleBulkCopyColumnMapping being set or retrieved.

Property Value

An OracleBulkCopyColumnMapping object at the specified index.

Exceptions

IndexOutOfRangeException - The specified index does not exist.

OracleBulkCopyColumnMappingCollection Public Methods

The OracleBulkCopyColumnMappingCollection public methods are listed in Table 17-16.

Table 17-16 OracleBulkCopyColumnMappingCollection Public Methods

Public Method Description

Add

Adds objects to the collection

Clear

Clears the contents of the collection

Contains

Returns a value indicating whether or not a specified OracleBulkCopyColumnMapping object exists in the collection

CopyTo

Copies the elements of the OracleBulkCopyColumnMappingCollection to an array of OracleBulkCopyColumnMapping items, starting at a specified index

IndexOf

Returns the index of the specified OracleBulkCopyColumnMapping object

Insert

Inserts a new OracleBulkCopyColumnMapping object in the collection, at the index specified.

Remove

Removes the specified OracleBulkCopyColumnMapping element from the OracleBulkCopyColumnMappingCollection.

RemoveAt

Removes the mapping from the collection at the specified index.


Add

Add methods add objects to the collection.

Overload List:

  • Add(OracleBulkCopyColumnMapping)

    This method adds the supplied OracleBulkCopyColumnMapping object to the collection.

  • Add(int, int)

    This method creates and adds an OracleBulkCopyColumnMapping object to the collection using the supplied source and destination column ordinal positions.

  • Add(int, string)

    This method creates and adds an OracleBulkCopyColumnMapping object to the collection using the supplied source column ordinal and destination column name.

  • Add(string, int)

    This method creates and adds an OracleBulkCopyColumnMapping object to the collection using the supplied source column name and destination column ordinal.

  • Add(string, string)

    This method creates and adds an OracleBulkCopyColumnMapping object to the collection using the supplied source and destination column names.

Add(OracleBulkCopyColumnMapping)

This method adds the supplied OracleBulkCopyColumnMapping object to the collection.

Declaration

// C#
public OracleBulkCopyColumnMapping Add(OracleBulkCopyColumnMapping
  bulkCopyColumnMapping);

Parameters

  • bulkCopyColumnMapping

    The OracleBulkCopyColumnMapping object that describes the mapping to be added to the collection.

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Add(int, int)

This method creates and adds an OracleBulkCopyColumnMapping object to the collection using the supplied source and destination column ordinal positions.

Declaration

// C#
public OracleBulkCopyColumnMapping Add(int sourceColumnIndex, 
    int destinationColumnIndex);

Parameters

  • sourceColumnIndex

    The ordinal position of the source column within the data source.

  • destinationColumnIndex

    The ordinal position of the destination column within the destination table.

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Return Value

The newly created OracleBulkCopyColumnMapping object that was added to the collection.

Remarks

It is not necessary to specify column mappings for all the columns in the data source. If a ColumnMapping is not specified, then, by default, columns are mapped based on the ordinal position. This succeeds only if the source and destination table schema match. If there is a mismatch, an InvalidOperationException is thrown.

All the mappings in a mapping collection must be by name or ordinal position.

Note:

Oracle Data Provider for .NET makes one or more round-trips to the database to determine the column name if the mapping is specified by ordinal position. To avoid this performance overhead, specify the mapping by column name.

Add(int, string)

This method creates and adds an OracleBulkCopyColumnMapping object to the collection using the supplied source column ordinal and destination column name.

Declaration

// C#
public OracleBulkCopyColumnMapping Add(int sourceColumnIndex, 
    string destinationColumn);

Parameters

  • sourceColumnIndex

    The ordinal position of the source column within the data source.

  • destinationColumn

    The name of the destination column within the destination table.

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Return Value

The newly created OracleBulkCopyColumnMapping object that was added to the collection.

Remarks

It is not necessary to specify column mappings for all the columns in the data source. If a ColumnMapping is not specified, then, by default, columns are mapped based on the ordinal position. This succeeds only if the source and destination table schema match. If there is a mismatch, an InvalidOperationException is thrown.

All the mappings in a mapping collection must be by name or ordinal position.

Note:

Oracle Data Provider for .NET makes one or more round trips to the database to determine the column names if the mapping is specified by ordinal resulting in a performance overhead. Therefore, it is recommended to specify the mapping by column names.

Add(string, int)

This method creates and adds an OracleBulkCopyColumnMapping object to the collection using the supplied source column name and destination column ordinal.

Declaration

// C#
public OracleBulkCopyColumnMapping Add(string sourceColumn, 
    int destinationColumnIndex);

Parameters

  • sourceColumn

    The name of the source column within the data source.

  • destinationColumnIndex

    The ordinal position of the destination column within the destination table.

Return Value

The newly created OracleBulkCopyColumnMapping object that was added to the collection.

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Remarks

It is not necessary to specify column mappings for all the columns in the data source. If a ColumnMapping is not specified, then, by default, columns are mapped based on the ordinal position. This succeeds only if the source and destination table schema match. If there is a mismatch, an InvalidOperationException is thrown.

All the mappings in a mapping collection must be by name or ordinal position.

Note:

Oracle Data Provider for .NET makes one or more round trips to the database to determine the column names if the mapping is specified by ordinal resulting in a performance overhead. Therefore, it is recommended to specify the mapping by column names.

Add(string, string)

This method creates and adds an OracleBulkCopyColumnMapping object to the collection using the supplied source and destination column names.

Declaration

// C#
public OracleBulkCopyColumnMapping Add(string sourceColumn, 
   string destinationColumn);

Parameters

  • sourceColumn

    The name of the source column within the data source.

  • destinationColumn

    The name of the destination column within the destination table.

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Return Value

The newly created OracleBulkCopyColumnMapping object that was added to the collection.

Remarks

It is not necessary to specify column mappings for all the columns in the data source. If a ColumnMapping is not specified, then, by default, columns are mapped based on the ordinal position. This succeeds only if the source and destination table schema match. If there is a mismatch, an InvalidOperationException is thrown.

All the mappings in a mapping collection must be by name or ordinal position.

Note:

Oracle Data Provider for .NET makes one or more round-trips to the database to determine the column name if the mapping is specified by ordinal position. To avoid this performance overhead, specify the mapping by column name.

Clear

This method clears the contents of the collection.

Declaration

// C#
public void Clear();

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Remarks

The Clear method is most commonly used when an application uses a single OracleBulkCopy instance to process more than one bulk copy operation. If column mappings are created for one bulk copy operation, the OracleBulkCopyColumnMappingCollection must be cleared after the WriteToServer method invocation and before the next bulk copy is processed.

It is usually more efficient to perform several bulk copies using the same OracleBulkCopy instance than to use a separate OracleBulkCopy for each operation.

Contains

This method returns a value indicating whether or not a specified OracleBulkCopyColumnMapping object exists in the collection.

Declaration

// C#
public bool Contains(OracleBulkCopyColumnMapping value);

Parameters

  • value

    A valid OracleBulkCopyColumnMapping object.

Return Value

Returns true if the specified mapping exists in the collection; otherwise, returns false.

CopyTo

This method copies the elements of the OracleBulkCopyColumnMappingCollection to an array of OracleBulkCopyColumnMapping items, starting at a specified index.

Declaration

// C#
public void CopyTo(OracleBulkCopyColumnMapping[] array, int index);

Parameters

  • array

    The one-dimensional OracleBulkCopyColumnMapping array that is the destination for the elements copied from the OracleBulkCopyColumnMappingCollection object. The array must have zero-based indexing.

  • index

    The zero-based array index at which copying begins.

IndexOf

This method returns the index of the specified OracleBulkCopyColumnMapping object.

Declaration

// C#
public int IndexOf(OracleBulkCopyColumnMapping value);

Parameters

  • value

    The OracleBulkCopyColumnMapping object that is being returned.

Return Value

The zero-based index of the column mapping or -1 if the column mapping is not found in the collection.

Insert

This method inserts a new OracleBulkCopyColumnMapping object in the collection, at the index specified.

Declaration

// C#
public void Insert(int index, OracleBulkCopyColumnMapping value);

Parameters

  • index

    The integer value of the location within the OracleBulkCopyColumnMappingCollection at which the new OracleBulkCopyColumnMapping is inserted.

  • value

    The OracleBulkCopyColumnMapping object to be inserted in the collection.

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Remove

This method removes the specified OracleBulkCopyColumnMapping element from the OracleBulkCopyColumnMappingCollection.

Declaration

// C#
public void Remove(OracleBulkCopyColumnMapping value);

Parameters

  • value

    The OracleBulkCopyColumnMapping object to be removed from the collection.

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Remarks

The Remove method is most commonly used when a single OracleBulkCopy instance processes more than one bulk copy operation. If column mappings are created for one bulk copy operation, mappings that no longer apply must be removed after the WriteToServer method invocation and before mappings are defined for the next bulk copy. The Clear method can clear the entire collection, and the Remove and the RemoveAt methods can remove mappings individually.

It is usually more efficient to perform several bulk copies using the same OracleBulkCopy instance than to use a separate OracleBulkCopy for each operation.

RemoveAt

This method removes the mapping from the collection at the specified index.

Declaration

// C#
public void RemoveAt(int index);

Parameters

  • index

    The zero-based index of the OracleBulkCopyColumnMapping object to be removed from the collection.

Exceptions

InvalidOperationException - The bulk copy operation is in progress.

Remarks

The RemoveAt method is most commonly used when a single OracleBulkCopy instance is used to process more than one bulk copy operation. If column mappings are created for one bulk copy operation, mappings that no longer apply must be removed after the WriteToServer method invocation and before the mappings for the next bulk copy are defined. The Clear method can clear the entire collection, and the Remove and the RemoveAt methods can remove mappings individually.

It is usually more efficient to perform several bulk copies using the same OracleBulkCopy instance than to use a separate OracleBulkCopy for each operation.