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.

C#
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DataTableMapping this[int index] { get; set; }
C#
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataTableMappings_Item")]
public System.Data.Common.DataTableMapping this[int index] { get; set; }

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.

C#
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);
}

Applies to

.NET 10 ja muut versiot
Tuote Versiot
.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

Item[String]

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

Gets or sets the DataTableMapping object with the specified source table name.

C#
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DataTableMapping this[string sourceTable] { get; set; }
C#
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataTableMappings_Item")]
public System.Data.Common.DataTableMapping this[string sourceTable] { get; set; }

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.

C#
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());
}

Applies to

.NET 10 ja muut versiot
Tuote Versiot
.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