DataColumn.ColumnMapping Eigenschaft

Definition

Ruft den MappingType der Spalte ab oder legt ihn fest.

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

Eigenschaftswert

MappingType

Einer der MappingType-Werte.

Attribute

Beispiele

Im folgenden Beispiel wird die ColumnMapping Typeigenschaft neuer DataColumn.

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

Hinweise

Die ColumnMapping Eigenschaft bestimmt, wie eine zugeordnet wird, wenn ein DataSet DataColumn DOKUMENT mithilfe der WriteXml Methode als XML-Dokument gespeichert wird.

Wenn beispielsweise eine DataColumn "customerID" lautet und die ColumnMapping Eigenschaft auf MappingType.Element"customerID" festgelegt ist, erzeugt der Spaltenwert die folgende XML-Datei:

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

Wenn jedoch dieselbe Spalte zugeordnet MappingType.Attributeist, wird die folgende XML-Datei erstellt:

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

Verwenden Sie den DataColumn Konstruktor, der das type Argument enthält, um anzugeben, wie die Zuordnung beim DataColumn Transformieren in ein XML-Dokument erfolgt DataSet .

Die ColumnMapping Eigenschaft entspricht dem Konstruktorargument type.

Gilt für

Siehe auch