DataColumnMappingCollection.Item[] 属性

定义

获取或设置指定的 DataColumnMapping 对象。

重载

Item[Int32]

获取或设置位于指定索引处的 DataColumnMapping 对象。

Item[String]

获取或设置具有指定源列名称的 DataColumnMapping 对象。

Item[Int32]

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

获取或设置位于指定索引处的 DataColumnMapping 对象。

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 对象的从零开始的索引。

属性值

指定索引处的 DataColumnMapping 对象。

属性

示例

以下示例创建一个 DataColumnMappingCollection 集合,将对象添加到 DataColumnMapping 集合,并显示映射的源列的列表。

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]

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

获取或设置具有指定源列名称的 DataColumnMapping 对象。

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

源列的区分大小写的名称。

属性值

具有指定源列名称的 DataColumnMapping 对象。

属性

示例

以下示例在集合中搜索 DataColumnMapping 具有给定源列名称的对象 DataColumnMappingCollectionDataColumnMapping如果 存在,则本示例显示映射的名称和索引。 如果映射不存在,则本示例显示错误。 此示例假定已创建集合 DataColumnMappingCollection

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

另请参阅

适用于