DataRow.GetParentRow 메서드

정의

DataRow의 부모 행을 가져옵니다.Gets the parent row of a DataRow.

오버로드

GetParentRow(DataRelation)

지정된 DataRow을 사용하여 DataRelation의 부모 행을 가져옵니다.Gets the parent row of a DataRow using the specified DataRelation.

GetParentRow(String)

DataRow의 지정된 RelationName을 사용하여 DataRelation의 부모 행을 가져옵니다.Gets the parent row of a DataRow using the specified RelationName of a DataRelation.

GetParentRow(DataRelation, DataRowVersion)

지정된 DataRowDataRelation을 사용하여 DataRowVersion의 부모 행을 가져옵니다.Gets the parent row of a DataRow using the specified DataRelation, and DataRowVersion.

GetParentRow(String, DataRowVersion)

DataRow의 지정된 RelationNameDataRelation을 사용하여 DataRowVersion의 부모 행을 가져옵니다.Gets the parent row of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.

GetParentRow(DataRelation)

지정된 DataRow을 사용하여 DataRelation의 부모 행을 가져옵니다.Gets the parent row of a DataRow using the specified DataRelation.

public:
 System::Data::DataRow ^ GetParentRow(System::Data::DataRelation ^ relation);
public System.Data.DataRow? GetParentRow (System.Data.DataRelation? relation);
public System.Data.DataRow GetParentRow (System.Data.DataRelation relation);
member this.GetParentRow : System.Data.DataRelation -> System.Data.DataRow
Public Function GetParentRow (relation As DataRelation) As DataRow

매개 변수

relation
DataRelation

사용할 DataRelation입니다.The DataRelation to use.

반환

DataRow

현재 행의 부모 DataRow를 반환합니다.The parent DataRow of the current row.

예외

relationDataTable에 속하지 않는 경우The relation does not belong to the DataTable.

또는-or-

행이 null인 경우The row is null.

자식 행에 여러 부모가 있습니다.A child row has multiple parents.

이 행이 DataRelation 개체의 자식 테이블에 속하지 않는 경우This row does not belong to the child table of the DataRelation object.

행이 테이블에 속하지 않는 경우The row does not belong to a table.

예제

다음 예제에서는를 사용 GetParentRow 하 여 DataRow 의 모든 자식에 대 한 자식 개체를 반환 합니다 DataRelation DataTable .The following example uses the GetParentRow to return the child DataRow objects for every child DataRelation in a DataTable. 그러면 행의 각 열 값이 출력 됩니다.The value of each column in the row is then printed.

private void GetParentRowForTable(DataTable thisTable,
    DataRelation relation)
{
    if(thisTable ==null){return;}
    // For each row in the table, print column 1
    // of the parent DataRow.
    DataRow parentRow;
    foreach(DataRow row in thisTable.Rows)
    {
        parentRow = row.GetParentRow(relation);
        Console.Write("\table child row: " + row[1]);
        Console.Write("\table parent row: " + parentRow[1]+ "\n");
    }
}

private void CallGetParentRowForTable()
{
    // An example of calling the function.
    DataTable thisTable = DataSet1.Tables["Products"];
    DataRelation relation = thisTable.ParentRelations[0];
    GetParentRowForTable(thisTable, relation);
}
Private Sub GetParentRowForTable _
   (thisTable As DataTable, relation As DataRelation)
    If thisTable Is Nothing Then
        Return
    End If
    ' For each row in the table, print column 1 
    ' of the parent DataRow.
    Dim parentRow As DataRow
    Dim row As DataRow
    For Each row In  thisTable.Rows
        parentRow = row.GetParentRow(relation)
        Console.Write(ControlChars.Tab & " child row: " _
           & row(1).ToString())
        Console.Write(ControlChars.Tab & " parent row: " _
           & parentRow(1).ToString() & ControlChars.Cr)
    Next row
End Sub
  
Private Sub CallGetParentRowForTable()
    ' An example of calling the function.
    Dim thisTable As DataTable = DataSet1.Tables("Products")
    Dim relation As DataRelation = thisTable.ParentRelations(0)
    GetParentRowForTable(thisTable, relation)
End Sub

설명

에서 DataSet DataRelation 데이터 집합에 대 한 모든 부모 개체의 컬렉션은 메서드에서 반환 됩니다 GetParentRows .In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

에는 DataTable 속성에 의해 반환 되는 개체의 컬렉션도 포함 DataRelation ParentRelations 됩니다.The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

추가 정보

적용 대상

GetParentRow(String)

DataRow의 지정된 RelationName을 사용하여 DataRelation의 부모 행을 가져옵니다.Gets the parent row of a DataRow using the specified RelationName of a DataRelation.

public:
 System::Data::DataRow ^ GetParentRow(System::String ^ relationName);
public System.Data.DataRow? GetParentRow (string? relationName);
public System.Data.DataRow GetParentRow (string relationName);
member this.GetParentRow : string -> System.Data.DataRow
Public Function GetParentRow (relationName As String) As DataRow

매개 변수

반환

DataRow

현재 행의 부모 DataRow를 반환합니다.The parent DataRow of the current row.

예외

관계와 행이 같은 테이블에 속하지 않는 경우The relation and row do not belong to the same table.

자식 행에 여러 부모가 있습니다.A child row has multiple parents.

행이 테이블에 속하지 않는 경우The row does not belong to the table.

예제

다음 예제에서는를 사용 하 여의 각 GetParentRow 부모 행에서 값을 인쇄 합니다 DataRow DataTable .The following example uses the GetParentRow to print a value from each parent row of each DataRow in a DataTable.

private void GetParentRowForTable(
    DataTable thisTable, string relation)
{
    if(thisTable ==null){return;}
    // For each row in the table, print column 1
    // of the parent DataRow.
    DataRow parentRow;
    foreach(DataRow row in thisTable.Rows)
    {
        parentRow = row.GetParentRow(relation);
        Console.Write("\table child row: " + row[1]);
        Console.Write("\table parent row: " + parentRow[1]+ "\n");
    }
}

private void CallGetParentRowForTable()
{
    // An example of calling the function.
    DataTable thisTable = DataSet1.Tables["Products"];
    DataRelation relation = thisTable.ParentRelations[0];
    GetParentRowForTable(thisTable, relation.RelationName);
}
Private Sub GetParentRowForTable( _
    thisTable As DataTable, relation As String)
     If thisTable Is Nothing Then
         Return
     End If

     ' For each row in the table, print column 1 
     ' of the parent DataRow.
     Dim parentRow As DataRow
     Dim row As DataRow
     For Each row In  thisTable.Rows
         parentRow = row.GetParentRow(relation)
         Console.Write(ControlChars.Tab + " child row: " _
            + row(1).ToString())
         Console.Write(ControlChars.Tab + " parent row: " _
            + parentRow(1).ToString() + ControlChars.Cr)
     Next row
End Sub    
    
Private Sub CallGetParentRowForTable()
     ' An example of calling the function.
     Dim thisTable As DataTable = DataSet1.Tables("Products")
     Dim relation As DataRelation = thisTable.ParentRelations(0)
     GetParentRowForTable(thisTable, relation.RelationName)
End Sub

설명

에서 DataSet DataRelation 데이터 집합에 대 한 모든 부모 개체의 컬렉션은 메서드에서 반환 됩니다 GetParentRows .In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

에는 DataTable 속성에 의해 반환 되는 개체의 컬렉션도 포함 DataRelation ParentRelations 됩니다.The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

적용 대상

GetParentRow(DataRelation, DataRowVersion)

지정된 DataRowDataRelation을 사용하여 DataRowVersion의 부모 행을 가져옵니다.Gets the parent row of a DataRow using the specified DataRelation, and DataRowVersion.

public:
 System::Data::DataRow ^ GetParentRow(System::Data::DataRelation ^ relation, System::Data::DataRowVersion version);
public System.Data.DataRow? GetParentRow (System.Data.DataRelation? relation, System.Data.DataRowVersion version);
public System.Data.DataRow GetParentRow (System.Data.DataRelation relation, System.Data.DataRowVersion version);
member this.GetParentRow : System.Data.DataRelation * System.Data.DataRowVersion -> System.Data.DataRow
Public Function GetParentRow (relation As DataRelation, version As DataRowVersion) As DataRow

매개 변수

relation
DataRelation

사용할 DataRelation입니다.The DataRelation to use.

version
DataRowVersion

가져올 데이터의 버전을 지정하는 DataRowVersion 값 중 하나입니다.One of the DataRowVersion values specifying the version of the data to get.

반환

DataRow

현재 행의 부모 DataRow를 반환합니다.The parent DataRow of the current row.

예외

행이 null인 경우The row is null.

또는-or-

relation이 이 테이블의 부모 관계에 속하지 않는 경우The relation does not belong to this table's parent relations.

자식 행에 여러 부모가 있습니다.A child row has multiple parents.

관계의 자식 테이블이 행이 속한 테이블이 아닌 경우The relation's child table is not the table the row belongs to.

행이 테이블에 속하지 않는 경우The row does not belong to a table.

행에 이 버전의 데이터가 없는 경우The row does not have this version of data.

예제

다음 예제에서는를 사용 GetParentRow 하 여 DataRow 의 모든 자식에 대 한 자식 개체를 반환 합니다 DataRelation DataTable .The following example uses the GetParentRow to return the child DataRow objects for every child DataRelation in a DataTable. 그러면 행의 각 열 값이 출력 됩니다.The value of each column in the row is then printed.

private void GetParentRowForTable(DataTable thisTable,
    DataRelation relation,
    DataRowVersion version)
{
    if(thisTable ==null){return;}
    // For each row in the table, print column 1 of the
    // parent DataRow.
    DataRow parentRow;
    foreach(DataRow row in thisTable.Rows)
    {
        parentRow = row.GetParentRow(relation, version);
        Console.Write("\table child row: " + row[1]);
        Console.Write("\table parent row: " + parentRow[1]+ "\n");
    }
}

private void CallGetParentRowForTable()
{
    // An example of calling the function.
    DataTable thisTable = DataSet1.Tables["Products"];
    DataRelation relation = thisTable.ParentRelations[0];
    // Print only original versions of parent rows.
    GetParentRowForTable(thisTable, relation,
        DataRowVersion.Original);
}
Private Sub GetParentRowForTable _
    (thisTable As DataTable, relation As DataRelation, _
    version As DataRowVersion)
    If thisTable Is Nothing Then
        Return
    End If

    ' For each row in the table, print column 1 
    ' of the parent DataRow.
    Dim parentRow As DataRow
    Dim row As DataRow
    For Each row In  thisTable.Rows
        parentRow = row.GetParentRow(relation, version)
        Console.Write(ControlChars.Tab & " child row: " & _
            row(1).ToString())
        Console.Write(ControlChars.Tab & " parent row: " _
            & parentRow(1).ToString() & ControlChars.Cr)
    Next row
End Sub

Private Sub CallGetParentRowForTable()
    ' An example of calling the function.
    Dim thisTable As DataTable = DataSet1.Tables("Products")
    Dim relation As DataRelation = thisTable.ParentRelations(0)

    ' Print only original versions of parent rows.
    GetParentRowForTable(thisTable, relation, _
        DataRowVersion.Original)
End Sub

설명

에서 DataSet DataRelation 데이터 집합에 대 한 모든 부모 개체의 컬렉션은 메서드에서 반환 됩니다 GetParentRows .In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

에는 DataTable 속성에 의해 반환 되는 개체의 컬렉션도 포함 DataRelation ParentRelations 됩니다.The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

원하는가 있는지 HasVersion 여부를 확인 하려면 속성을 사용 DataRowVersion 합니다.Use the HasVersion property to determine whether the DataRowVersion that you want exists.

추가 정보

적용 대상

GetParentRow(String, DataRowVersion)

DataRow의 지정된 RelationNameDataRelation을 사용하여 DataRowVersion의 부모 행을 가져옵니다.Gets the parent row of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.

public:
 System::Data::DataRow ^ GetParentRow(System::String ^ relationName, System::Data::DataRowVersion version);
public System.Data.DataRow? GetParentRow (string? relationName, System.Data.DataRowVersion version);
public System.Data.DataRow GetParentRow (string relationName, System.Data.DataRowVersion version);
member this.GetParentRow : string * System.Data.DataRowVersion -> System.Data.DataRow
Public Function GetParentRow (relationName As String, version As DataRowVersion) As DataRow

매개 변수

version
DataRowVersion

DataRowVersion 값 중 하나입니다.One of the DataRowVersion values.

반환

DataRow

현재 행의 부모 DataRow를 반환합니다.The parent DataRow of the current row.

예외

관계와 행이 같은 테이블에 속하지 않는 경우The relation and row do not belong to the same table.

relationnull인 경우The relation is null.

자식 행에 여러 부모가 있습니다.A child row has multiple parents.

행이 테이블에 속하지 않는 경우The row does not belong to the table.

행에 요청한 DataRowVersion이 없는 경우The row does not have the requested DataRowVersion.

예제

다음 예제에서는를 사용 하 여의 각 GetParentRow 부모 행에서 값을 인쇄 합니다 DataRow DataTable .The following example uses the GetParentRow to print a value from each parent row of each DataRow in a DataTable.

private void GetParentRowForTable(DataTable thisTable,
    string relation, DataRowVersion version)
{
    if(thisTable ==null){return;}
    // For each row in the table, print column 1
    // of the parent DataRow.
    DataRow parentRow;
    foreach(DataRow row in thisTable.Rows)
    {
        parentRow = row.GetParentRow(relation, version);
        Console.Write("\t child row: " + row[1]);
        Console.Write("\t parent row: " + parentRow[1]+ "\n");
    }
}

private void CallGetParentRowForTable()
{
    // An example of calling the function.
    DataTable thisTable = DataSet1.Tables["Products"];
    DataRelation relation = thisTable.ParentRelations[0];

    // Print only original versions of parent rows.
    GetParentRowForTable(thisTable, relation.RelationName,
        DataRowVersion.Original);
}
Private Sub GetParentRowForTable _
    (thisTable As DataTable, relation As String, _
    version As DataRowVersion)
     If thisTable Is Nothing Then
         Return
     End If
     ' For each row in the table, print column 1 
     ' of the parent DataRow.
     Dim parentRow As DataRow
     Dim row As DataRow
     For Each row In  thisTable.Rows
         parentRow = row.GetParentRow(relation, version)
         Console.Write(ControlChars.Tab & " child row: " _
            & row(1).ToString())
         Console.Write(ControlChars.Tab & " parent row: " _
            & parentRow(1).ToString() & ControlChars.Cr)
     Next row
End Sub
   
Private Sub CallGetParentRowForTable()
     ' An example of calling the function.
     Dim thisTable As DataTable = DataSet1.Tables("Products")
     Dim relation As DataRelation = thisTable.ParentRelations(0)
     ' Print only original versions of parent rows.
     GetParentRowForTable(thisTable, relation.RelationName, _
        DataRowVersion.Original)
End Sub

설명

에서 DataSet DataRelation 데이터 집합에 대 한 모든 부모 개체의 컬렉션은 메서드에서 반환 됩니다 GetParentRows .In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

에는 DataTable 속성에 의해 반환 되는 개체의 컬렉션도 포함 DataRelation ParentRelations 됩니다.The DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

원하는가 있는지 HasVersion 여부를 확인 하려면 속성을 사용 DataRowVersion 합니다.Use the HasVersion property to determine whether the DataRowVersion that you want exists.

적용 대상