DataRow.GetParentRow Metoda

Definicja

Pobiera wiersz nadrzędny elementu DataRow.

Przeciążenia

GetParentRow(DataRelation)

Pobiera wiersz DataRow nadrzędny elementu przy użyciu określonego DataRelationelementu .

GetParentRow(String)

Pobiera wiersz DataRow nadrzędny elementu przy użyciu określonego RelationName elementu DataRelation.

GetParentRow(DataRelation, DataRowVersion)

Pobiera wiersz DataRow nadrzędny elementu przy użyciu określonej wartości DataRelationi DataRowVersion.

GetParentRow(String, DataRowVersion)

Pobiera wiersz DataRow nadrzędny elementu przy użyciu określonej wartości RelationNameDataRelation, i DataRowVersion.

GetParentRow(DataRelation)

Źródło:
DataRow.cs
Źródło:
DataRow.cs
Źródło:
DataRow.cs

Pobiera wiersz DataRow nadrzędny elementu przy użyciu określonego DataRelationelementu .

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

Parametry

relation
DataRelation

Do DataRelation użycia.

Zwraca

Element nadrzędny DataRow bieżącego wiersza.

Wyjątki

Element relation nie należy do klasy DataTable.

-lub-

Wiersz to null.

Wiersz podrzędny ma wielu rodziców.

Ten wiersz nie należy do tabeli podrzędnej DataRelation obiektu.

Wiersz nie należy do tabeli.

Przykłady

W poniższym przykładzie użyto elementu , GetParentRow aby zwrócić obiekty podrzędne dla każdego elementu podrzędnego DataRowDataRelation w obiekcie DataTable. Wartość każdej kolumny w wierszu jest następnie drukowana.

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

Uwagi

W obiekcie DataSetkolekcja wszystkich obiektów nadrzędnych DataRelation dla zestawu danych jest zwracana przez metodę GetParentRows .

Obiekt DataTable zawiera również kolekcję obiektów zwróconych DataRelation przez ParentRelations właściwość .

Zobacz też

Dotyczy

GetParentRow(String)

Źródło:
DataRow.cs
Źródło:
DataRow.cs
Źródło:
DataRow.cs

Pobiera wiersz DataRow nadrzędny elementu przy użyciu określonego RelationName elementu 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

Parametry

relationName
String

Element RelationName .DataRelation

Zwraca

Element nadrzędny DataRow bieżącego wiersza.

Wyjątki

Relacja i wiersz nie należą do tej samej tabeli.

Wiersz podrzędny ma wielu rodziców.

Wiersz nie należy do tabeli.

Przykłady

W poniższym przykładzie użyto elementu , GetParentRow aby wydrukować wartość z każdego wiersza nadrzędnego każdego z nich DataRow w elemecie 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

Uwagi

W obiekcie DataSetkolekcja wszystkich obiektów nadrzędnych DataRelation dla zestawu danych jest zwracana przez metodę GetParentRows .

Obiekt DataTable zawiera również kolekcję obiektów zwróconych DataRelation przez ParentRelations właściwość .

Dotyczy

GetParentRow(DataRelation, DataRowVersion)

Źródło:
DataRow.cs
Źródło:
DataRow.cs
Źródło:
DataRow.cs

Pobiera wiersz DataRow nadrzędny elementu przy użyciu określonej wartości DataRelationi 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

Parametry

relation
DataRelation

Do DataRelation użycia.

version
DataRowVersion

DataRowVersion Jedna z wartości określających wersję danych do pobrania.

Zwraca

Element nadrzędny DataRow bieżącego wiersza.

Wyjątki

Wiersz to null.

-lub-

Element relation nie należy do relacji nadrzędnych tej tabeli.

Wiersz podrzędny ma wielu rodziców.

Tabela podrzędna relacji nie jest tabelą, do którego należy wiersz.

Wiersz nie należy do tabeli.

Wiersz nie ma tej wersji danych.

Przykłady

W poniższym przykładzie użyto elementu , GetParentRow aby zwrócić obiekty podrzędne dla każdego elementu podrzędnego DataRowDataRelation w obiekcie DataTable. Wartość każdej kolumny w wierszu jest następnie drukowana.

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

Uwagi

W obiekcie DataSetkolekcja wszystkich obiektów nadrzędnych DataRelation dla zestawu danych jest zwracana przez metodę GetParentRows .

Obiekt DataTable zawiera również kolekcję obiektów zwróconych DataRelation przez ParentRelations właściwość .

Użyj właściwości , HasVersion aby określić, czy DataRowVersion chcesz istnieć.

Zobacz też

Dotyczy

GetParentRow(String, DataRowVersion)

Źródło:
DataRow.cs
Źródło:
DataRow.cs
Źródło:
DataRow.cs

Pobiera wiersz DataRow nadrzędny elementu przy użyciu określonej wartości RelationNameDataRelation, i 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

Parametry

relationName
String

Element RelationName .DataRelation

version
DataRowVersion

Jedna z DataRowVersion wartości.

Zwraca

Element nadrzędny DataRow bieżącego wiersza.

Wyjątki

Relacja i wiersz nie należą do tej samej tabeli.

Element relation to null.

Wiersz podrzędny ma wielu rodziców.

Wiersz nie należy do tabeli.

Wiersz nie ma żądanego DataRowVersionelementu .

Przykłady

W poniższym przykładzie użyto elementu , GetParentRow aby wydrukować wartość z każdego wiersza nadrzędnego każdego z nich DataRow w elemecie 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

Uwagi

W obiekcie DataSetkolekcja wszystkich obiektów nadrzędnych DataRelation dla zestawu danych jest zwracana przez metodę GetParentRows .

Obiekt DataTable zawiera również kolekcję obiektów zwróconych DataRelation przez ParentRelations właściwość .

Użyj właściwości , HasVersion aby określić, czy DataRowVersion chcesz istnieć.

Dotyczy