DataColumn.ColumnMapping Proprietà
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta l'oggetto MappingType della colonna.
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
Uno dei valori di MappingType.
- Attributi
Nell'esempio seguente viene impostata la ColumnMapping proprietà type di new 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
La ColumnMapping proprietà determina la modalità di mapping di un DataColumn oggetto quando un DataSet oggetto viene salvato come documento XML utilizzando il WriteXml metodo .
Ad esempio, se un DataColumn oggetto è denominato "customerID" e la relativa ColumnMapping proprietà è impostata su MappingType.Element
, il valore della colonna produrrà il codice XML seguente:
<Customers>
<customerID>ALFKI</customerID>
......
</Customers>
<Orders>
<OrderID>12345</OrderID>
<customerID>ALFKI</customerID>
......
</Orders>
Tuttavia, se viene eseguito il mapping della stessa colonna a MappingType.Attribute
, viene generato il codice XML seguente:
<Customers customerID="ALFKI"........more attributes.....>
<Order orderID="1234"....more attributes..../>
<Order orderID="1234"....more attributes..../>
...... More orders for this customer
</Customers>
Utilizzare il DataColumn costruttore che contiene l'argomento type
per specificare la modalità di mapping dell'oggetto DataColumn quando viene DataSet trasformato in un documento XML.
La ColumnMapping proprietà corrisponde all'argomento type
del costruttore .
Prodotto | Versioni |
---|---|
.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 |
Feedback su .NET
.NET è un progetto open source. Seleziona un collegamento per fornire feedback: