DataTableMappingCollection.GetTableMappingBySchemaAction Method

Definition

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

C#
public static System.Data.Common.DataTableMapping? GetTableMappingBySchemaAction(System.Data.Common.DataTableMappingCollection? tableMappings, string sourceTable, string dataSetTable, System.Data.MissingMappingAction mappingAction);
C#
public static System.Data.Common.DataTableMapping GetTableMappingBySchemaAction(System.Data.Common.DataTableMappingCollection tableMappings, string sourceTable, string dataSetTable, System.Data.MissingMappingAction mappingAction);

Parameters

tableMappings
DataTableMappingCollection

The DataTableMappingCollection collection to search.

sourceTable
String

The case-sensitive name of the mapped source table.

dataSetTable
String

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

mappingAction
MissingMappingAction

One of the MissingMappingAction values.

Returns

A DataTableMapping object.

Exceptions

The mappingAction parameter was set to Error, and no mapping was specified.

Examples

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.

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

Remarks

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 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.
Error An exception is generated. The dataSetTable parameter is ignored.
Ignore Gets null. The dataSetTable parameter is ignored.

Applies to

Produkt Verzie
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1