DataAdapter.TableMappings Property

Definition

Gets a collection that provides the primary mapping between a source table and a DataTable.

C#
public System.Data.Common.DataTableMappingCollection TableMappings { get; }
C#
[System.Data.DataSysDescription("DataAdapter_TableMappings")]
public System.Data.Common.DataTableMappingCollection TableMappings { get; }

Property Value

A collection that provides the primary mapping between the returned records and the DataSet. The default value is an empty collection.

Attributes

Examples

The following example uses a derived class, OleDbDataAdapter, to add DataTableMapping objects to its TableMappings collection and display a list of those mapped source tables. This example assumes that an OleDbDataAdapter has already been created.

C#
public void ShowTableMappings() {
   // ...
   // create myDataAdapter
   // ...
   myDataAdapter.TableMappings.Add("Categories","DataCategories");
   myDataAdapter.TableMappings.Add("Orders","DataOrders");
   myDataAdapter.TableMappings.Add("Products","DataProducts");
   string myMessage = "Table Mappings:\n";
   for(int i=0;i < myDataAdapter.TableMappings.Count;i++) {
      myMessage += i.ToString() + " "
         + myDataAdapter.TableMappings[i].ToString() + "\n";
   }
   MessageBox.Show(myMessage);
}

Remarks

When reconciling changes, the DataAdapter uses the DataTableMappingCollection collection to associate the column names used by the data source with the column names used by the DataSet.

Applies to

Product Versions
.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

See also