MySqlBulkCopyColumnMapping constructor (1 of 2)
Initializes MySqlBulkCopyColumnMapping
with the default values.
public MySqlBulkCopyColumnMapping()
See Also
- class MySqlBulkCopyColumnMapping
- namespace MySqlConnector
- assembly MySqlConnector
MySqlBulkCopyColumnMapping constructor (2 of 2)
Use MySqlBulkCopyColumnMapping
to specify how to map columns in the source data to columns in the destination table when using MySqlBulkCopy
.
Set SourceOrdinal
to the zero-based index of the source column to map. Set DestinationColumn
to either the name of a column in the destination table, or the name of a user-defined variable. If a user-defined variable, you can use Expression
to specify a MySQL expression that assigns its value to destination column.
Source columns that don’t have an entry in ColumnMappings
will be ignored (unless the ColumnMappings
collection is empty, in which case all columns will be mapped one-to-one).
MySqlConnector will transmit all binary data as hex, so any expression that operates on it must decode it with the UNHEX
function first. (This will be performed automatically if no Expression
is specified, but will be necessary to specify manually for more complex expressions.)
Example code:
new MySqlBulkCopyColumnMapping
{
SourceOrdinal = 2,
DestinationColumn = "user_name",
},
new MySqlBulkCopyColumnMapping
{
SourceOrdinal = 0,
DestinationColumn = "@tmp",
Expression = "column_value = @tmp * 2",
},
public MySqlBulkCopyColumnMapping(int sourceOrdinal, string destinationColumn,
string? expression = null)
parameter | description |
---|---|
sourceOrdinal | The zero-based ordinal position of the source column. |
destinationColumn | The name of the destination column. |
expression | The optional expression to be used to set the destination column. |
See Also
- class MySqlBulkCopyColumnMapping
- namespace MySqlConnector
- assembly MySqlConnector