DataRow.GetParentRow Metoda

Definicja

Pobiera wiersz nadrzędny DataRow.

Przeciążenia

GetParentRow(DataRelation)

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

GetParentRow(String)

Pobiera wiersz nadrzędny DataRow przy użyciu określonej RelationNameDataRelation.

GetParentRow(DataRelation, DataRowVersion)

Pobiera wiersz nadrzędny DataRow przy użyciu określonego DataRelationi DataRowVersion.

GetParentRow(String, DataRowVersion)

Pobiera wiersz nadrzędny DataRow przy użyciu określonej RelationNameDataRelationi DataRowVersion.

GetParentRow(DataRelation)

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

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

C#
public System.Data.DataRow? GetParentRow (System.Data.DataRelation? relation);
C#
public System.Data.DataRow GetParentRow (System.Data.DataRelation relation);

Parametry

relation
DataRelation

DataRelation do użycia.

Zwraca

Nadrzędna DataRow bieżącego wiersza.

Wyjątki

relation nie należy do DataTable.

-lub-

Wiersz jest null.

Wiersz podrzędny ma wielu rodziców.

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

Wiersz nie należy do tabeli.

Przykłady

W poniższym przykładzie użyto GetParentRow do zwrócenia obiektów podrzędnych DataRow dla każdego DataRelation podrzędnego w DataTable. Następnie jest drukowana wartość każdej kolumny w wierszu.

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

Uwagi

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

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

Zobacz też

Dotyczy

.NET 9 i inne wersje
Produkt Wersje
.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

GetParentRow(String)

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

Pobiera wiersz nadrzędny DataRow przy użyciu określonej RelationNameDataRelation.

C#
public System.Data.DataRow? GetParentRow (string? relationName);
C#
public System.Data.DataRow GetParentRow (string relationName);

Parametry

Zwraca

Nadrzędna 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 GetParentRow do wydrukowania wartości z każdego wiersza nadrzędnego każdego DataRow w DataTable.

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

Uwagi

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

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

Dotyczy

.NET 9 i inne wersje
Produkt Wersje
.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

GetParentRow(DataRelation, DataRowVersion)

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

Pobiera wiersz nadrzędny DataRow przy użyciu określonego DataRelationi DataRowVersion.

C#
public System.Data.DataRow? GetParentRow (System.Data.DataRelation? relation, System.Data.DataRowVersion version);
C#
public System.Data.DataRow GetParentRow (System.Data.DataRelation relation, System.Data.DataRowVersion version);

Parametry

relation
DataRelation

DataRelation do użycia.

version
DataRowVersion

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

Zwraca

Nadrzędna DataRow bieżącego wiersza.

Wyjątki

Wiersz jest null.

-lub-

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 GetParentRow do zwrócenia obiektów podrzędnych DataRow dla każdego DataRelation podrzędnego w DataTable. Następnie jest drukowana wartość każdej kolumny w wierszu.

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

Uwagi

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

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

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

Zobacz też

Dotyczy

.NET 9 i inne wersje
Produkt Wersje
.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

GetParentRow(String, DataRowVersion)

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

Pobiera wiersz nadrzędny DataRow przy użyciu określonej RelationNameDataRelationi DataRowVersion.

C#
public System.Data.DataRow? GetParentRow (string? relationName, System.Data.DataRowVersion version);
C#
public System.Data.DataRow GetParentRow (string relationName, System.Data.DataRowVersion version);

Parametry

version
DataRowVersion

Jedna z wartości DataRowVersion.

Zwraca

Nadrzędna DataRow bieżącego wiersza.

Wyjątki

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

relation jest null.

Wiersz podrzędny ma wielu rodziców.

Wiersz nie należy do tabeli.

Wiersz nie ma żądanego DataRowVersion.

Przykłady

W poniższym przykładzie użyto GetParentRow do wydrukowania wartości z każdego wiersza nadrzędnego każdego DataRow w DataTable.

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

Uwagi

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

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

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

Dotyczy

.NET 9 i inne wersje
Produkt Wersje
.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