DataColumnMappingCollection.Item[] Property

Definition

Gets or sets the DataColumnMapping object specified.

Overloads

Item[Int32]

Gets or sets the DataColumnMapping object at the specified index.

Item[String]

Gets or sets the DataColumnMapping object with the specified source column name.

Item[Int32]

Source:
DataColumnMappingCollection.cs
Source:
DataColumnMappingCollection.cs
Source:
DataColumnMappingCollection.cs

Gets or sets the DataColumnMapping object at the specified index.

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

Parameters

index
Int32

The zero-based index of the DataColumnMapping object to find.

Property Value

The DataColumnMapping object at the specified index.

Attributes

Examples

The following example creates a DataColumnMappingCollection collection, adds DataColumnMapping objects to the collection, and displays a list of the mapped source columns.

C#
public void CreateColumnMappings()
{
    DataColumnMappingCollection mappings =
        new DataColumnMappingCollection();
    mappings.Add("Category Name","DataCategory");
    mappings.Add("Description","DataDescription");
    mappings.Add("Picture","DataPicture");
    string message = "ColumnMappings:\n";
    for(int i=0;i < mappings.Count;i++)
    {
        message += i.ToString() + " "
            + mappings[i].ToString() + "\n";
    }
    Console.WriteLine(message);
}

See also

Applies to

.NET 10 and other versions
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

Item[String]

Source:
DataColumnMappingCollection.cs
Source:
DataColumnMappingCollection.cs
Source:
DataColumnMappingCollection.cs

Gets or sets the DataColumnMapping object with the specified source column name.

C#
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DataColumnMapping this[string sourceColumn] { get; set; }
C#
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataColumnMappings_Item")]
public System.Data.Common.DataColumnMapping this[string sourceColumn] { get; set; }

Parameters

sourceColumn
String

The case-sensitive name of the source column.

Property Value

The DataColumnMapping object with the specified source column name.

Attributes

Examples

The following example searches for a DataColumnMapping object with the given source column name within a DataColumnMappingCollection collection. If the DataColumnMapping 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 DataColumnMappingCollection collection has been created.

C#
public void FindDataColumnMapping()
{
    // ...
    // create columnMappings
    // ...
    if (!columnMappings.Contains("Description"))
    {
        Console.WriteLine("Error: no such table in collection.");
    }
    else
    {
        Console.WriteLine("Name {0}",
            columnMappings["Description"].ToString());
        Console.WriteLine("Index: {0}",
            columnMappings.IndexOf("Description").ToString());
    }
}

See also

Applies to

.NET 10 and other versions
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