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 값 중 하나입니다.

특성

예제

다음 예제에서는 새 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 메서드를 사용하여 WriteXmlDataColumn XML 문서로 저장할 때 를 DataSet 매핑하는 방법을 결정합니다.

예를 들어 이름이 DataColumn "customerID"이고 해당 ColumnMapping 속성이 로 MappingType.Element설정된 경우 열 값은 다음 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에 해당합니다.

적용 대상

추가 정보