DataColumnMappingCollection.GetColumnMappingBySchemaAction Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a DataColumnMapping for the specified DataColumnMappingCollection, source column name, and MissingMappingAction.
public:
static System::Data::Common::DataColumnMapping ^ GetColumnMappingBySchemaAction(System::Data::Common::DataColumnMappingCollection ^ columnMappings, System::String ^ sourceColumn, System::Data::MissingMappingAction mappingAction);
public static System.Data.Common.DataColumnMapping? GetColumnMappingBySchemaAction (System.Data.Common.DataColumnMappingCollection? columnMappings, string sourceColumn, System.Data.MissingMappingAction mappingAction);
public static System.Data.Common.DataColumnMapping GetColumnMappingBySchemaAction (System.Data.Common.DataColumnMappingCollection columnMappings, string sourceColumn, System.Data.MissingMappingAction mappingAction);
static member GetColumnMappingBySchemaAction : System.Data.Common.DataColumnMappingCollection * string * System.Data.MissingMappingAction -> System.Data.Common.DataColumnMapping
Public Shared Function GetColumnMappingBySchemaAction (columnMappings As DataColumnMappingCollection, sourceColumn As String, mappingAction As MissingMappingAction) As DataColumnMapping
Parameters
- columnMappings
- DataColumnMappingCollection
- sourceColumn
- String
The case-sensitive source column name to find.
- mappingAction
- MissingMappingAction
One of the MissingMappingAction values.
Returns
A DataColumnMapping object.
Exceptions
The mappingAction
parameter was set to Error
, and no mapping was specified.
Examples
The following example searches for a DataColumnMapping with the given source column name within the collection. If the object exists, it is returned. The example assumes that a DataColumnMappingCollection collection and a DataColumnMapping object have been created.
public void FindDataColumnMapping()
{
// ...
// create mappings and mapping
// ...
if (mappings.Contains("Description"))
mapping = DataColumnMappingCollection.GetColumnMappingBySchemaAction
(mappings, "Description", MissingMappingAction.Ignore);
}
Public Sub FindDataColumnMapping()
' ...
' create mappings and mapping
' ...
If mappings.Contains("Description") Then
mapping = _
DataColumnMappingCollection.GetColumnMappingBySchemaAction _
(mappings, "Description", MissingMappingAction.Ignore)
End If
End Sub
Remarks
If the DataColumnMapping exists in the collection, it is returned.
If the DataColumnMapping does not exist in the collection, for a given MissingMappingAction, the following actions occur:
MissingMappingAction | Action Taken |
---|---|
Passthrough |
Creates a DataColumnMapping with the specified source column name as both the source column name and the DataSet column name. This DataColumnMapping is not added to the collection. |
Error |
An InvalidOperationException is generated if the specified column mapping is missing. |
Ignore |
Gets a null value. |