DataAdapter.TableMappings Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection that provides the primary mapping between a source table and a DataTable.
public:
property System::Data::Common::DataTableMappingCollection ^ TableMappings { System::Data::Common::DataTableMappingCollection ^ get(); };
public System.Data.Common.DataTableMappingCollection TableMappings { get; }
[System.Data.DataSysDescription("DataAdapter_TableMappings")]
public System.Data.Common.DataTableMappingCollection TableMappings { get; }
member this.TableMappings : System.Data.Common.DataTableMappingCollection
[<System.Data.DataSysDescription("DataAdapter_TableMappings")>]
member this.TableMappings : System.Data.Common.DataTableMappingCollection
Public ReadOnly Property TableMappings As DataTableMappingCollection
A collection that provides the primary mapping between the returned records and the DataSet. The default value is an empty collection.
- Attributes
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.
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);
}
Public Sub ShowTableMappings()
' ...
' create myDataAdapter
' ...
myDataAdapter.TableMappings.Add("Categories", "DataCategories")
myDataAdapter.TableMappings.Add("Orders", "DataOrders")
myDataAdapter.TableMappings.Add("Products", "DataProducts")
Dim myMessage As String = "Table Mappings:" + ControlChars.Cr
Dim i As Integer
For i = 0 To myDataAdapter.TableMappings.Count - 1
myMessage += i.ToString() + " " _
+ myDataAdapter.TableMappings(i).ToString() + ControlChars.Cr
Next i
MessageBox.Show(myMessage)
End Sub
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.
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 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: