DataColumn.ColumnMapping Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define o MappingType da coluna.
public:
virtual property System::Data::MappingType ColumnMapping { System::Data::MappingType get(); void set(System::Data::MappingType value); };
[System.Data.DataSysDescription("DataColumnMappingDescr")]
public virtual System.Data.MappingType ColumnMapping { get; set; }
public virtual System.Data.MappingType ColumnMapping { get; set; }
[<System.Data.DataSysDescription("DataColumnMappingDescr")>]
member this.ColumnMapping : System.Data.MappingType with get, set
member this.ColumnMapping : System.Data.MappingType with get, set
Public Overridable Property ColumnMapping As MappingType
Valor de Propriedade
Um dos MappingType valores.
- Atributos
Exemplos
O exemplo seguinte define a ColumnMapping propriedade de tipo de novo 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
Observações
A ColumnMapping propriedade determina como a DataColumn é mapeado quando a DataSet é guardado como documento XML usando o WriteXml método.
Por exemplo, se a DataColumn for chamado "customerID" e a sua ColumnMapping propriedade for definida para MappingType.Element, o valor da coluna produzirá o seguinte XML:
<Customers>
<customerID>ALFKI</customerID>
......
</Customers>
<Orders>
<OrderID>12345</OrderID>
<customerID>ALFKI</customerID>
......
</Orders>
No entanto, se a mesma coluna for mapeada para MappingType.Attribute, é produzido o seguinte XML:
<Customers customerID="ALFKI"........more attributes.....>
<Order orderID="1234"....more attributes..../>
<Order orderID="1234"....more attributes..../>
...... More orders for this customer
</Customers>
Use o DataColumn construtor que contém o type argumento para especificar como o DataColumn é mapeado quando DataSet é transformado num documento XML.
A ColumnMapping propriedade corresponde ao argumento typedo construtor .