Condividi tramite


DataRow.GetParentRow Metodo

Definizione

Ottiene la riga padre di un oggetto DataRow.

Overload

Nome Descrizione
GetParentRow(DataRelation)

Ottiene la riga padre di un DataRow oggetto utilizzando l'oggetto specificato DataRelation.

GetParentRow(String)

Ottiene la riga padre di un DataRow oggetto utilizzando l'oggetto specificato RelationName di un oggetto DataRelation.

GetParentRow(DataRelation, DataRowVersion)

Ottiene la riga padre di un DataRow oggetto utilizzando l'oggetto specificato DataRelatione DataRowVersion.

GetParentRow(String, DataRowVersion)

Ottiene la riga padre di un DataRow oggetto utilizzando l'oggetto specificato RelationName di un DataRelationoggetto e DataRowVersion.

GetParentRow(DataRelation)

Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs

Ottiene la riga padre di un DataRow oggetto utilizzando l'oggetto specificato 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

Parametri

relation
DataRelation

Oggetto DataRelation da utilizzare.

Restituisce

Elemento padre DataRow della riga corrente.

Eccezioni

L'oggetto relation non appartiene all'oggetto DataTable.

oppure

La riga è null.

Una riga figlio ha più elementi padre.

Questa riga non appartiene alla tabella figlio dell'oggetto DataRelation .

La riga non appartiene a una tabella.

Esempio

Nell'esempio seguente viene utilizzato per GetParentRow restituire gli oggetti figlio per ogni elemento figlio DataRowDataRelation in un oggetto DataTable. Il valore di ogni colonna nella riga viene quindi stampato.

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

Commenti

In un DataSetoggetto , la raccolta di tutti gli oggetti padre DataRelation per il set di dati viene restituita dal GetParentRows metodo .

Contiene DataTable inoltre una raccolta di DataRelation oggetti restituiti dalla ParentRelations proprietà .

Vedi anche

Si applica a

GetParentRow(String)

Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs

Ottiene la riga padre di un DataRow oggetto utilizzando l'oggetto specificato RelationName di un oggetto 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

Parametri

relationName
String

Oggetto RelationName di un oggetto DataRelation.

Restituisce

Elemento padre DataRow della riga corrente.

Eccezioni

La relazione e la riga non appartengono alla stessa tabella.

Una riga figlio ha più elementi padre.

La riga non appartiene alla tabella.

Esempio

Nell'esempio seguente viene utilizzato per GetParentRow stampare un valore da ogni riga padre di ogni DataRow oggetto in un oggetto 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

Commenti

In un DataSetoggetto , la raccolta di tutti gli oggetti padre DataRelation per il set di dati viene restituita dal GetParentRows metodo .

Contiene DataTable inoltre una raccolta di DataRelation oggetti restituiti dalla ParentRelations proprietà .

Si applica a

GetParentRow(DataRelation, DataRowVersion)

Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs

Ottiene la riga padre di un DataRow oggetto utilizzando l'oggetto specificato DataRelatione 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

Parametri

relation
DataRelation

Oggetto DataRelation da utilizzare.

version
DataRowVersion

Uno dei DataRowVersion valori che specifica la versione dei dati da ottenere.

Restituisce

Elemento padre DataRow della riga corrente.

Eccezioni

La riga è null.

oppure

Non relation appartiene alle relazioni padre della tabella.

Una riga figlio ha più elementi padre.

La tabella figlio della relazione non è la tabella a cui appartiene la riga.

La riga non appartiene a una tabella.

La riga non dispone di questa versione di dati.

Esempio

Nell'esempio seguente viene utilizzato per GetParentRow restituire gli oggetti figlio per ogni elemento figlio DataRowDataRelation in un oggetto DataTable. Il valore di ogni colonna nella riga viene quindi stampato.

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

Commenti

In un DataSetoggetto , la raccolta di tutti gli oggetti padre DataRelation per il set di dati viene restituita dal GetParentRows metodo .

Contiene DataTable inoltre una raccolta di DataRelation oggetti restituiti dalla ParentRelations proprietà .

Utilizzare la HasVersion proprietà per determinare se l'oggetto DataRowVersion desiderato esiste.

Vedi anche

Si applica a

GetParentRow(String, DataRowVersion)

Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs
Origine:
DataRow.cs

Ottiene la riga padre di un DataRow oggetto utilizzando l'oggetto specificato RelationName di un DataRelationoggetto e 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

Parametri

relationName
String

Oggetto RelationName di un oggetto DataRelation.

version
DataRowVersion

Uno dei DataRowVersion valori.

Restituisce

Elemento padre DataRow della riga corrente.

Eccezioni

La relazione e la riga non appartengono alla stessa tabella.

Una riga figlio ha più elementi padre.

La riga non appartiene alla tabella.

La riga non dispone dell'oggetto richiesto DataRowVersion.

Esempio

Nell'esempio seguente viene utilizzato per GetParentRow stampare un valore da ogni riga padre di ogni DataRow oggetto in un oggetto 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

Commenti

In un DataSetoggetto , la raccolta di tutti gli oggetti padre DataRelation per il set di dati viene restituita dal GetParentRows metodo .

Contiene DataTable inoltre una raccolta di DataRelation oggetti restituiti dalla ParentRelations proprietà .

Utilizzare la HasVersion proprietà per determinare se l'oggetto DataRowVersion desiderato esiste.

Si applica a