Leer en inglés

Compartir vía


DataRow.GetParentRow Método

Definición

Obtiene la fila primaria de DataRow.

Sobrecargas

GetParentRow(DataRelation)

Obtiene la fila primaria de un DataRow mediante el DataRelation especificado.

GetParentRow(String)

Obtiene la fila primaria de DataRow mediante el RelationName especificado de DataRelation.

GetParentRow(DataRelation, DataRowVersion)

Obtiene la fila primaria de DataRow mediante el DataRelation especificado y DataRowVersion.

GetParentRow(String, DataRowVersion)

Obtiene la fila primaria de un DataRow mediante el RelationName especificado de un DataRelation y DataRowVersion.

GetParentRow(DataRelation)

Source:
DataRow.cs
Source:
DataRow.cs
Source:
DataRow.cs

Obtiene la fila primaria de un DataRow mediante el DataRelation especificado.

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

Parámetros

relation
DataRelation

Objeto DataRelation que se va a usar.

Devoluciones

DataRow primario de la fila actual.

Excepciones

relation no pertenece a DataTable.

o bien

La fila es null.

Una fila secundaria tiene varios elementos primarios.

Esta fila no pertenece a la tabla secundaria del objeto DataRelation.

La fila no pertenece a una tabla.

Ejemplos

En el ejemplo siguiente se usa GetParentRow para devolver los objetos secundarios DataRow de cada elemento secundario DataRelation de .DataTable A continuación, se imprime el valor de cada columna de la fila.

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

Comentarios

En un DataSet, el método devuelve GetParentRows la colección de todos los objetos primarios DataRelation del conjunto de datos.

DataTable también contiene una colección de DataRelation objetos, devuelto por la ParentRelations propiedad .

Consulte también

Se aplica a

.NET 9 otras versiones
Producto Versiones
.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)

Source:
DataRow.cs
Source:
DataRow.cs
Source:
DataRow.cs

Obtiene la fila primaria de DataRow mediante el RelationName especificado de DataRelation.

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

Parámetros

relationName
String

RelationName de un DataRelation.

Devoluciones

DataRow primario de la fila actual.

Excepciones

La relación y la fila no pertenecen a la misma tabla.

Una fila secundaria tiene varios elementos primarios.

La fila no pertenece a la tabla.

Ejemplos

En el GetParentRow ejemplo siguiente se usa para imprimir un valor de cada fila primaria de cada DataRow una de ellas en .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);
}

Comentarios

En un DataSet, el método devuelve GetParentRows la colección de todos los objetos primarios DataRelation del conjunto de datos.

DataTable también contiene una colección de DataRelation objetos, devuelto por la ParentRelations propiedad .

Se aplica a

.NET 9 otras versiones
Producto Versiones
.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)

Source:
DataRow.cs
Source:
DataRow.cs
Source:
DataRow.cs

Obtiene la fila primaria de DataRow mediante el DataRelation especificado y 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);

Parámetros

relation
DataRelation

Objeto DataRelation que se va a usar.

version
DataRowVersion

Uno de los valores de DataRowVersion que especifica la versión de los datos que se va a obtener.

Devoluciones

DataRow primario de la fila actual.

Excepciones

La fila es null.

o bien

relation no pertenece a las relaciones primarias de esta tabla.

Una fila secundaria tiene varios elementos primarios.

La tabla secundaria de la relación no es la tabla a la que pertenece la fila.

La fila no pertenece a una tabla.

La fila no tiene esta versión de datos.

Ejemplos

En el ejemplo siguiente se usa GetParentRow para devolver los objetos secundarios DataRow de cada elemento secundario DataRelation de .DataTable A continuación, se imprime el valor de cada columna de la fila.

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

Comentarios

En un DataSet, el método devuelve GetParentRows la colección de todos los objetos primarios DataRelation del conjunto de datos.

DataTable también contiene una colección de DataRelation objetos, devuelto por la ParentRelations propiedad .

Utilice la HasVersion propiedad para determinar si existe el DataRowVersion que desea.

Consulte también

Se aplica a

.NET 9 otras versiones
Producto Versiones
.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)

Source:
DataRow.cs
Source:
DataRow.cs
Source:
DataRow.cs

Obtiene la fila primaria de un DataRow mediante el RelationName especificado de un DataRelation y 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);

Parámetros

relationName
String

RelationName de un DataRelation.

version
DataRowVersion

Uno de los valores de DataRowVersion.

Devoluciones

DataRow primario de la fila actual.

Excepciones

La relación y la fila no pertenecen a la misma tabla.

El valor de relation es null.

Una fila secundaria tiene varios elementos primarios.

La fila no pertenece a la tabla.

La fila no tiene el DataRowVersion solicitado.

Ejemplos

En el GetParentRow ejemplo siguiente se usa para imprimir un valor de cada fila primaria de cada DataRow una de ellas en .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);
}

Comentarios

En un DataSet, el método devuelve GetParentRows la colección de todos los objetos primarios DataRelation del conjunto de datos.

DataTable también contiene una colección de DataRelation objetos, devuelto por la ParentRelations propiedad .

Utilice la HasVersion propiedad para determinar si existe el DataRowVersion que desea.

Se aplica a

.NET 9 otras versiones
Producto Versiones
.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