DataColumnMappingCollection.Item[] Özellik
Tanım
Belirtilen nesneyi alır veya ayarlar DataColumnMapping .Gets or sets the DataColumnMapping object specified.
Aşırı Yüklemeler
Item[Int32] |
DataColumnMappingBelirtilen dizindeki nesneyi alır veya ayarlar.Gets or sets the DataColumnMapping object at the specified index. |
Item[String] |
DataColumnMappingBelirtilen kaynak sütun adına sahip nesneyi alır veya ayarlar.Gets or sets the DataColumnMapping object with the specified source column name. |
Item[Int32]
DataColumnMappingBelirtilen dizindeki nesneyi alır veya ayarlar.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
Parametreler
- index
- Int32
Bulunacak nesnenin sıfır tabanlı dizini DataColumnMapping .The zero-based index of the DataColumnMapping object to find.
Özellik Değeri
DataColumnMappingBelirtilen dizindeki nesne.The DataColumnMapping object at the specified index.
- Öznitelikler
Örnekler
Aşağıdaki örnek bir koleksiyon oluşturur DataColumnMappingCollection , DataColumnMapping koleksiyona nesneler ekler ve eşlenmiş kaynak sütunlarının bir listesini görüntüler.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
Ayrıca bkz.
Şunlara uygulanır
Item[String]
DataColumnMappingBelirtilen kaynak sütun adına sahip nesneyi alır veya ayarlar.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
Parametreler
- sourceColumn
- String
Kaynak sütunun büyük/küçük harfe duyarlı adı.The case-sensitive name of the source column.
Özellik Değeri
DataColumnMappingBelirtilen kaynak sütun adına sahip nesne.The DataColumnMapping object with the specified source column name.
- Öznitelikler
Örnekler
Aşağıdaki örnek, DataColumnMapping bir koleksiyon içinde verilen kaynak sütun adına sahip bir nesne arar DataColumnMappingCollection .The following example searches for a DataColumnMapping object with the given source column name within a DataColumnMappingCollection collection. Varsa DataColumnMapping , örnek, eşlemenin adını ve dizinini görüntüler.If the DataColumnMapping exists, the example displays the name and the index of the mapping. Eşleme yoksa, örnek bir hata görüntüler.If the mapping does not exist, the example displays an error. Bu örnek DataColumnMappingCollection , bir koleksiyonun oluşturulduğunu varsayar.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