DataColumn.ColumnMapping プロパティ

定義

列の MappingType を取得します。値の設定も可能です。

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

プロパティ値

MappingType 値のいずれか 1 つ。

属性

次の例では、新しい DataColumnColumnMapping type プロパティを設定します。

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

注釈

プロパティは ColumnMapping 、 メソッドを DataColumn 使用して XML ドキュメントとして を保存するときに DataSet 、 をマップする方法を WriteXml 決定します。

たとえば、 が "customerID" という名前で、そのColumnMappingプロパティが にMappingType.Element設定されている場合DataColumn、列の値は次の XML を生成します。

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

ただし、同じ列が に MappingType.Attributeマップされている場合は、次の XML が生成されます。

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

引数をDataColumn含むコンストラクターをtype使用して、 が XML ドキュメントに変換されるときに DataSetDataColumnマップ方法を指定します。

プロパティは ColumnMapping 、コンストラクター引数 に対応します type

適用対象

こちらもご覧ください