DataColumn.ColumnMapping プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
列の 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 つ。
- 属性
次の例では、新しい DataColumnの ColumnMapping 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 ドキュメントに変換されるときに DataSet のDataColumnマップ方法を指定します。
プロパティは 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 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。