DataTableMappingCollection.Item[] Property    
Definition
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 or sets the DataTableMapping object specified.
Overloads
| Item[Int32] | Gets or sets the DataTableMapping object at the specified index. | 
| Item[String] | Gets or sets the DataTableMapping object with the specified source table name. | 
Item[Int32]
Gets or sets the DataTableMapping object at the specified index.
public:
 property System::Data::Common::DataTableMapping ^ default[int] { System::Data::Common::DataTableMapping ^ get(int index); void set(int index, System::Data::Common::DataTableMapping ^ value); };[System.ComponentModel.Browsable(false)]
public System.Data.Common.DataTableMapping this[int index] { get; set; }[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataTableMappings_Item")]
public System.Data.Common.DataTableMapping this[int index] { get; set; }[<System.ComponentModel.Browsable(false)>]
member this.Item(int) : System.Data.Common.DataTableMapping with get, set[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataTableMappings_Item")>]
member this.Item(int) : System.Data.Common.DataTableMapping with get, setDefault Public Property Item(index As Integer) As DataTableMappingParameters
- index
- Int32
The zero-based index of the DataTableMapping object to return.
Property Value
The DataTableMapping object at the specified index.
- Attributes
Examples
The following example creates a DataTableMappingCollection collection, adds DataTableMapping objects to the collection, and displays a list of the mapped source tables.
public void CreateTableMappings()
{
    DataTableMappingCollection mappings =
        new DataTableMappingCollection();
    mappings.Add("Categories","DataCategories");
    mappings.Add("Orders","DataOrders");
    mappings.Add("Products","DataProducts");
    string message = "TableMappings:\n";
    for(int i=0;i < mappings.Count;i++)
    {
        message += i.ToString() + " "
            + mappings[i].ToString() + "\n";
    }
    Console.WriteLine(message);
}
Public Sub CreateTableMappings()
    Dim mappings As New DataTableMappingCollection()
    mappings.Add("Categories", "DataCategories")
    mappings.Add("Orders", "DataOrders")
    mappings.Add("Products", "DataProducts")
    Dim message As String = "TableMappings:" + ControlChars.Cr
    Dim i As Integer
    For i = 0 To mappings.Count - 1
        message &= i.ToString() & " " & mappings(i).ToString() _
           & ControlChars.Cr
    Next i
    Console.WriteLine(message)
End Sub
Applies to
Item[String]
Gets or sets the DataTableMapping object with the specified source table name.
public:
 property System::Data::Common::DataTableMapping ^ default[System::String ^] { System::Data::Common::DataTableMapping ^ get(System::String ^ sourceTable); void set(System::String ^ sourceTable, System::Data::Common::DataTableMapping ^ value); };[System.ComponentModel.Browsable(false)]
public System.Data.Common.DataTableMapping this[string sourceTable] { get; set; }[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataTableMappings_Item")]
public System.Data.Common.DataTableMapping this[string sourceTable] { get; set; }[<System.ComponentModel.Browsable(false)>]
member this.Item(string) : System.Data.Common.DataTableMapping with get, set[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataTableMappings_Item")>]
member this.Item(string) : System.Data.Common.DataTableMapping with get, setDefault Public Property Item(sourceTable As String) As DataTableMappingParameters
- sourceTable
- String
The case-sensitive name of the source table.
Property Value
The DataTableMapping object with the specified source table name.
- Attributes
Examples
The following example searches for a DataTableMapping object with the given source table name within a DataTableMappingCollection collection. If the DataTableMapping exists, the example displays the name and the index of the mapping. If the mapping does not exist, the example displays an error. This example assumes that a DataTableMappingCollection collection has been created.
public void FindDataTableMapping()
{
    // ...
    // create mappings
    // ...
    if (!mappings.Contains("Categories"))
        Console.WriteLine("Error: no such table in collection");
    else
        Console.WriteLine
            ("Name: " + mappings["Categories"].ToString() + "\n"
            + "Index: " + mappings.IndexOf("Categories").ToString());
}
Public Sub FindDataTableMapping()
    ' ...
    ' create mappings
    ' ...
    If Not mappings.Contains("Categories") Then
        Console.WriteLine("Error: no such table in collection")
    Else
        Console.WriteLine("Name: " & mappings("Categories").ToString() _
           & ControlChars.Cr + "Index: " _
           & mappings.IndexOf("Categories").ToString())
    End If
End Sub