DataTableMappingCollection.GetTableMappingBySchemaAction Method (DataTableMappingCollection, String, String, MissingMappingAction)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets a DataColumnMapping object with the specified source table name and DataSet table name, using the given MissingMappingAction.

Namespace:   System.Data.Common
Assembly:  System.Data (in System.Data.dll)

public static DataTableMapping GetTableMappingBySchemaAction(
	DataTableMappingCollection tableMappings,
	string sourceTable,
	string dataSetTable,
	MissingMappingAction mappingAction


Type: System.Data.Common.DataTableMappingCollection

The DataTableMappingCollection collection to search.

Type: System.String

The case-sensitive name of the mapped source table.

Type: System.String

The name, which is not case-sensitive, of the mapped DataSet table.

Type: System.Data.MissingMappingAction

One of the MissingMappingAction values.

Exception Condition

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:


Action taken


Creates a DataTableMapping object with the given sourceTable as the source table name and dataSetTable as the DataSet table name. The created DataTableMapping object is not added to the collection.


An exception is generated. The dataSetTable parameter is ignored.


Gets null. The dataSetTable parameter is ignored.

The following example searches for a DataTableMapping with the given source table name within the collection. If the object exists, it is returned. The example assumes that a DataTableMappingCollection collection and a DataTableMapping object have been created.

public void FindDataTableMapping() 
    // ...
    // create mappings and mapping
    // ...
    if (mappings.Contains("Categories")) 
        mapping = DataTableMappingCollection.GetTableMappingBySchemaAction
            (mappings, "Categories", "", MissingMappingAction.Ignore);

.NET Framework
Available since 1.1
Return to top