System.Data.Common Namespace DataColumnMappingCollection Class
Returns a DataColumnMapping for the specified DataColumnMappingCollection, SourceColumn name, and MissingMappingAction.
[ VB ]
Public Shared Function GetColumnMappingBySchemaAction ( _
ByVal columnMappings As DataColumnMappingCollection, _
ByVal sourceColumn As String, _
ByVal mappingAction As MissingMappingAction _
) As DataColumnMapping
[ C# ]
public static DataColumnMapping GetColumnMappingBySchemaAction (
DataColumnMappingCollection columnMappings,
string sourceColumn,
MissingMappingAction mappingAction
);
[ C++ ]
public: static DataColumnMapping* GetColumnMappingBySchemaAction (
DataColumnMappingCollection* columnMappings,
String* sourceColumn,
MissingMappingAction mappingAction
);
[ JScript ]
public static function GetColumnMappingBySchemaAction (
columnMappings : DataColumnMappingCollection,
sourceColumn : String,
mappingAction : MissingMappingAction
) : DataColumnMapping
- columnMappings
- The DataColumnMappingCollection.
- sourceColumn
- The case-sensitive name of a SourceColumn to find.
- mappingAction
- One of the MissingMappingAction values.
A DataColumnMapping object.
Exception Type |
Condition |
InvalidOperationException |
The mappingAction parameter was set to Error, and no mapping was specified. |
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 happens:
MissingMappingAction |
Action Taken |
Passthrough |
This method initializes a DataColumnMapping with the given source column name as both the source column name and the DataSet column name. This DataColumnMapping is not added to the collection. |
Error |
An exception is generated. |
Ignore |
Gets a null. |
The following example demonstrates using the GetColumnMappingBySchemaAction method to return a specified DataColumnMapping object.
public void FindDataColumnMapping ( DataTableMapping myTableMap ) {
// get column mappings
DataColumnMappingCollection myFieldsMaps = myTableMap.ColumnMappings;
if ( myFieldsMaps.Contains ( "Description" ) ) {
DataColumnMapping myFieldMap =
DataColumnMappingCollection.GetColumnMappingBySchemaAction
( myFieldsMaps, "Description", MissingMappingAction.Ignore );
}
}
Public Sub FindDataColumnMapping ( ByVal myTableMap As DataTableMapping )
' get column mappings
Dim myFieldsMaps As DataColumnMappingCollection = myTableMap.ColumnMappings;
If myFieldsMaps.Contains ( "Description" ) Then
Dim myFieldMap As DataColumnMapping = _
DataColumnMappingCollection.GetColumnMappingBySchemaAction _
( myFieldsMaps, "Description", MissingMappingAction.Ignore )
End If
End Sub |
|
C# |
VB |
DataColumnMappingCollection Members