System.Data.Common Namespace DataTableMappingCollection Class
Returns the DataTableMapping object with the given SourceTable name and DataSetTable name, using the given MissingMappingAction.
[ VB ]
Public Shared Function GetTableMappingBySchemaAction ( _
ByVal tableMappings As DataTableMappingCollection, _
ByVal sourceTable As String, _
ByVal dataSetTable As String, _
ByVal mappingAction As MissingMappingAction _
) As DataTableMapping
[ C# ]
public static DataTableMapping GetTableMappingBySchemaAction (
DataTableMappingCollection tableMappings,
string sourceTable,
string dataSetTable,
MissingMappingAction mappingAction
);
[ C++ ]
public: static DataTableMapping* GetTableMappingBySchemaAction (
DataTableMappingCollection* tableMappings,
String* sourceTable,
String* dataSetTable,
MissingMappingAction mappingAction
);
[ JScript ]
public static function GetTableMappingBySchemaAction (
tableMappings : DataTableMappingCollection,
sourceTable : String,
dataSetTable : String,
mappingAction : MissingMappingAction
) : DataTableMapping;
- tableMappings
- The DataTableMappingCollection to search.
- sourceTable
- The case-sensitive name of the SourceTable to find.
- dataSetTable
- The case-insensitive name of the mapped DataSetTable.
- mappingAction
- One of the MissingMappingAction values.
A DataTableMapping object.
Exception Type |
Condition |
InvalidOperationException |
The mappingAction parameter was set to Error, and no mapping was specified. |
If the DataTableMapping exists in the collection, it is returned.
If the DataTableMapping does not exist in the collection, for a given MissingMappingAction, the following happens:
MissingMappingAction |
Action Taken |
Passthrough |
This method initializes a DataTableMapping with the given sourceTable as the source table name and dataSetTable as the DataSet table name. This DataTableMapping object is not added to the collection. |
Error |
An exception is generated. The dataSetTable parameter is ignored. |
Ignore |
Gets a null. The dataSetTable parameter is ignored. |
The following example demonstrates using the GetTableMappingBySchemaAction method to return a specified DataTableMapping object.
public void FindDataTableMapping ( DataAdapter myAdapter ) {
// get table mappings
DataTableMappingCollection myTables = myAdapter.TableMappings;
if ( myTables.Contains ( "Employees" ) ) {
DataTableMapping myTable =
DataTableMappingCollection.GetTableMappingBySchemaAction
( myTables, "Employees", "", MissingMappingAction.Ignore );
}
}
Public Sub FindDataTableMapping ( ByVal myAdapter As DataAdapter )
' get table mappings
Dim myTables As DataTableMappingCollection = myAdapter.TableMappings;
If myTables.Contains ( "Employees" ) Then
Dim myTable As DataTableMapping = _
DataTableMappingCollection.GetTableMappingBySchemaAction _
( myTables, "Employees", "", MissingMappingAction.Ignore )
End If
End Sub |
|
C# |
VB |
DataTableMappingCollection Members