Aracılığıyla paylaş


DataColumn.ColumnMapping Özellik

Tanım

Sütunu alır MappingType veya ayarlar.

public:
 virtual property System::Data::MappingType ColumnMapping { System::Data::MappingType get(); void set(System::Data::MappingType value); };
public virtual System.Data.MappingType ColumnMapping { get; set; }
[System.Data.DataSysDescription("DataColumnMappingDescr")]
public virtual System.Data.MappingType ColumnMapping { get; set; }
member this.ColumnMapping : System.Data.MappingType with get, set
[<System.Data.DataSysDescription("DataColumnMappingDescr")>]
member this.ColumnMapping : System.Data.MappingType with get, set
Public Overridable Property ColumnMapping As MappingType

Özellik Değeri

Değerlerden MappingType biri.

Öznitelikler

Örnekler

Aşağıdaki örnek, yeni DataColumnöğesinin ColumnMapping type özelliğini ayarlar.

private void AddColumn(DataTable table)
{
    // Create a new column and set its properties.
    DataColumn column = new DataColumn("column",
        typeof(int), "", MappingType.Attribute);
    column.DataType = Type.GetType("System.String");
    column.ColumnMapping = MappingType.Element;

    // Add the column the table's columns collection.
    table.Columns.Add(column);
}
Private Sub AddColumn(table As DataTable )
    ' Create a new column and set its properties.
    Dim column As New DataColumn("ID", _
        Type.GetType("System.Int32"), "", MappingType.Attribute)
    column.DataType = Type.GetType("System.String")
    column.ColumnMapping = MappingType.Element

    ' Add the column the table's columns collection.
    table.Columns.Add(column)
End Sub

Açıklamalar

özelliği, ColumnMapping yöntemini kullanarak bir DataColumn XML belgesi olarak kaydedildiğinde a'nın DataSetWriteXml nasıl eşleneceğini belirler.

Örneğin, a DataColumn "customerID" olarak adlandırılırsa ve ColumnMapping özelliği olarak MappingType.Elementayarlanırsa, sütun değeri aşağıdaki XML'yi üretir:

<Customers>
 <customerID>ALFKI</customerID>
......
 </Customers>
 <Orders>
 <OrderID>12345</OrderID>
 <customerID>ALFKI</customerID>
......
 </Orders>

Ancak, aynı sütun ile eşlenmişse MappingType.Attributeaşağıdaki XML oluşturulur:

<Customers customerID="ALFKI"........more attributes.....>
 <Order orderID="1234"....more attributes..../>
 <Order orderID="1234"....more attributes..../>
...... More orders for this customer
 </Customers>

bağımsız değişkenini içeren oluşturucuyu DataColumntype kullanarak xml belgesine dönüştürüldüğünde DataSet öğesinin DataColumn nasıl eşleneceğini belirtin.

ColumnMapping özelliği oluşturucu bağımsız değişkenine typekarşılık gelir.

Şunlara uygulanır

Ayrıca bkz.