英語で読む

次の方法で共有


DataColumn.ColumnMapping プロパティ

定義

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

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

プロパティ値

MappingType 値のいずれか 1 つ。

属性

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

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

注釈

プロパティは 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

適用対象

製品 バージョン
.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

こちらもご覧ください