Breyta

Deila með


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.

public:
 property System::Data::Common::DataColumnMapping ^ default[int] { System::Data::Common::DataColumnMapping ^ get(int index); void set(int index, System::Data::Common::DataColumnMapping ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DataColumnMapping this[int index] { get; set; }
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataColumnMappings_Item")]
public System.Data.Common.DataColumnMapping this[int index] { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Item(int) : System.Data.Common.DataColumnMapping with get, set
[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataColumnMappings_Item")>]
member this.Item(int) : System.Data.Common.DataColumnMapping with get, set
Default Public Property Item(index As Integer) As DataColumnMapping

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.

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);
}
Public Sub CreateColumnMappings()
    Dim mappings As New DataColumnMappingCollection()
    mappings.Add("Category Name", "DataCategory")
    mappings.Add("Description", "DataDescription")
    mappings.Add("Picture", "DataPicture")
    Dim message As String = "ColumnMappings:" + 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

See also

Applies to

Item[String]

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

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

public:
 property System::Data::Common::DataColumnMapping ^ default[System::String ^] { System::Data::Common::DataColumnMapping ^ get(System::String ^ sourceColumn); void set(System::String ^ sourceColumn, System::Data::Common::DataColumnMapping ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DataColumnMapping this[string sourceColumn] { get; set; }
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataColumnMappings_Item")]
public System.Data.Common.DataColumnMapping this[string sourceColumn] { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Item(string) : System.Data.Common.DataColumnMapping with get, set
[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataColumnMappings_Item")>]
member this.Item(string) : System.Data.Common.DataColumnMapping with get, set
Default Public Property Item(sourceColumn As String) As DataColumnMapping

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.

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());
    }
}
Public Sub FindDataColumnMapping()
    ' ...
    ' create columnMappings
    ' ...
    If Not columnMappings.Contains("Description") Then
        Console.WriteLine("Error: no such table in collection.")
    Else
       Console.WriteLine("Name: {0}", _
           columnMappings("Description").ToString())
       Console.WriteLine("Index: {0}", _
           columnMappings.IndexOf("Description").ToString())
    End If
End Sub

See also

Applies to