DataColumn.ColumnMapping Tulajdonság

Definíció

Lekéri vagy beállítja az MappingType oszlopot.

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

Tulajdonság értéke

Az egyik MappingType érték.

Attribútumok

Példák

Az alábbi példa az ColumnMapping új DataColumntípustulajdonságot állítja be.

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

Megjegyzések

A ColumnMapping tulajdonság határozza meg, hogyan DataColumn van megfeleltetve a rendszer egy DataSet XML-dokumentumként való mentéskor a WriteXml metódus használatával.

Ha például egy DataColumn "customerID" nevű, és a tulajdonsága ColumnMapping a következőre MappingType.Elementvan állítva, az oszlop értéke a következő XML-t hozza létre:

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

Ha azonban ugyanarra az oszlopra van megfeleltetve MappingType.Attribute, a következő XML jön létre:

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

DataColumn Az argumentumot tartalmazó type konstruktor használatával megadhatja, hogy a DataColumn rendszer hogyan képezze le az argumentumot, amikor DataSet az XML-dokumentummá alakul.

A ColumnMapping tulajdonság a konstruktor argumentumnak typefelel meg.

A következőre érvényes:

Lásd még