Επεξεργασία

Κοινή χρήση μέσω


DataTableMappingCollection.Item[] Property

Definition

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]

Source:
DataTableMappingCollection.cs
Source:
DataTableMappingCollection.cs
Source:
DataTableMappingCollection.cs

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, set
Default Public Property Item(index As Integer) As DataTableMapping

Parameters

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]

Source:
DataTableMappingCollection.cs
Source:
DataTableMappingCollection.cs
Source:
DataTableMappingCollection.cs

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, set
Default Public Property Item(sourceTable As String) As DataTableMapping

Parameters

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

Applies to