DataColumn.ColumnMapping Propiedad

Definición

Obtiene o establece la enumeración MappingType de la columna.

C#
public virtual System.Data.MappingType ColumnMapping { get; set; }
C#
[System.Data.DataSysDescription("DataColumnMappingDescr")]
public virtual System.Data.MappingType ColumnMapping { get; set; }

Valor de propiedad

Uno de los valores de MappingType.

Atributos

Ejemplos

En el ejemplo siguiente se establece la ColumnMapping propiedad type de new DataColumn.

C#
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);
}

Comentarios

La ColumnMapping propiedad determina cómo se asigna un DataColumn objeto cuando DataSet se guarda como un documento XML mediante el WriteXml método .

Por ejemplo, si se DataColumn denomina "customerID" y su ColumnMapping propiedad se establece MappingType.Elementen , el valor de columna generará el siguiente CÓDIGO XML:

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

Sin embargo, si la misma columna se asigna a MappingType.Attribute, se genera el siguiente XML:

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

Use el DataColumn constructor que contiene el type argumento para especificar cómo se asigna cuando DataColumnDataSet se transforma en un documento XML.

La ColumnMapping propiedad corresponde al argumento typeconstructor .

Se aplica a

Producto Versiones
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Consulte también