DataColumn.ColumnMapping Eigenschap

Definitie

Hiermee haalt u de MappingType kolom op of stelt u deze in.

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

Waarde van eigenschap

Een van de MappingType waarden.

Kenmerken

Voorbeelden

In het volgende voorbeeld wordt de ColumnMapping typeeigenschap van nieuw DataColumningesteld.

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

Opmerkingen

De ColumnMapping eigenschap bepaalt hoe een DataColumn wordt toegewezen wanneer een wordt DataSet opgeslagen als een XML-document met behulp van de WriteXml methode.

Als een DataColumn naam bijvoorbeeld 'customerID' heeft en ColumnMapping de eigenschap is ingesteld op MappingType.Element, produceert de kolomwaarde de volgende XML:

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

Als dezelfde kolom echter is toegewezen MappingType.Attributeaan, wordt de volgende XML geproduceerd:

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

Gebruik de DataColumn constructor die het type argument bevat om op te geven hoe het wordt toegewezen wanneer DataColumn het DataSet wordt getransformeerd naar een XML-document.

De ColumnMapping eigenschap komt overeen met het argument typeconstructor.

Van toepassing op

Zie ook