DataColumnMappingCollection.Item[] 属性

定义

获取或设置指定的 DataColumnMapping 对象。Gets or sets the DataColumnMapping object specified.

重载

Item[Int32]

获取或设置位于指定索引处的 DataColumnMapping 对象。Gets or sets the DataColumnMapping object at the specified index.

Item[String]

获取或设置具有指定源列名称的 DataColumnMapping 对象。Gets or sets the DataColumnMapping object with the specified source column name.

Item[Int32]

获取或设置位于指定索引处的 DataColumnMapping 对象。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

参数

index
Int32

要查找的 DataColumnMapping 对象的从零开始的索引。The zero-based index of the DataColumnMapping object to find.

属性值

DataColumnMapping

指定索引处的 DataColumnMapping 对象。The DataColumnMapping object at the specified index.

属性

示例

下面的示例创建一个 DataColumnMappingCollection 集合,将 DataColumnMapping 对象添加到集合,并显示映射的源列的列表。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

适用于

Item[String]

获取或设置具有指定源列名称的 DataColumnMapping 对象。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

参数

sourceColumn
String

源列的区分大小写的名称。The case-sensitive name of the source column.

属性值

DataColumnMapping

具有指定源列名称的 DataColumnMapping 对象。The DataColumnMapping object with the specified source column name.

属性

示例

下面的示例在 DataColumnMapping 集合中搜索具有给定源列名称的对象 DataColumnMappingCollectionThe following example searches for a DataColumnMapping object with the given source column name within a DataColumnMappingCollection collection. 如果 DataColumnMapping 存在,则该示例显示映射的名称和索引。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. 此示例假设 DataColumnMappingCollection 已创建一个集合。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

适用于