DataRow.GetParentRows 方法

定义

获取 DataRow 的父行。Gets the parent rows of a DataRow.

重载

GetParentRows(DataRelation, DataRowVersion)

使用指定的 DataRelationDataRowVersion 获取 DataRow 的父行。Gets the parent rows of a DataRow using the specified DataRelation, and DataRowVersion.

GetParentRows(DataRelation)

使用指定的 DataRelation 获取 DataRow 的父行。Gets the parent rows of a DataRow using the specified DataRelation.

GetParentRows(String)

使用 DataRelation 的指定 RelationName 获取 DataRow 的父行。Gets the parent rows of a DataRow using the specified RelationName of a DataRelation.

GetParentRows(String, DataRowVersion)

使用 DataRelation 的指定 RelationNameDataRowVersion 获取 DataRow 的父行。Gets the parent rows of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.

GetParentRows(DataRelation, DataRowVersion)

使用指定的 DataRelationDataRowVersion 获取 DataRow 的父行。Gets the parent rows of a DataRow using the specified DataRelation, and DataRowVersion.

public:
 cli::array <System::Data::DataRow ^> ^ GetParentRows(System::Data::DataRelation ^ relation, System::Data::DataRowVersion version);
public System.Data.DataRow[] GetParentRows (System.Data.DataRelation? relation, System.Data.DataRowVersion version);
public System.Data.DataRow[] GetParentRows (System.Data.DataRelation relation, System.Data.DataRowVersion version);
member this.GetParentRows : System.Data.DataRelation * System.Data.DataRowVersion -> System.Data.DataRow[]
Public Function GetParentRows (relation As DataRelation, version As DataRowVersion) As DataRow()

参数

relation
DataRelation

要使用的 DataRelationThe DataRelation to use.

version
DataRowVersion

DataRowVersion 值之一,指定要获取的数据的版本。One of the DataRowVersion values specifying the version of the data to get.

返回

DataRow[]

一个 DataRow 对象数组,或长度为零的数组。An array of DataRow objects or an array of length zero.

例外

DataRelation 不属于此行的 DataSetThe DataRelation does not belong to this row's DataSet.

该行为 nullThe row is null.

此关系的子表不是该行所属的表。The relation's child table is not the table the row belongs to.

该行不属于 DataTableThe row does not belong to a DataTable.

该行没有请求的 DataRowVersionThe row does not have the requested DataRowVersion.

示例

下面的示例使用 GetParentRows 返回 DataRow 中每个子对象的子对象 DataRelation DataTableThe following example uses the GetParentRows 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 Sub GetChildRowsFromDataRelation(table As DataTable, ver As DataRowVersion)
    Dim relation As DataRelation
    Dim arrRows() As DataRow
    Dim row As DataRow
    Dim i As Integer
    Dim column As DataColumn 
 
    For Each relation In table.ParentRelations
      For Each row In table.Rows
          arrRows = row.GetParentRows(relation, ver)
          ' Print values of rows.
          For i = 0 To arrRows.GetUpperBound(0)
             For Each column in table.Columns
                Console.WriteLine(arrRows(i)(column.ColumnName))
             Next column
          Next i
       Next row
    Next relation
End Sub

注解

在中 DataSet ,该数据集的所有父对象的集合 DataRelationGetParentRows 方法返回。In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

DataTable还包含 DataRelation 由属性返回的对象的集合 ParentRelationsThe 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.

另请参阅

适用于

GetParentRows(DataRelation)

使用指定的 DataRelation 获取 DataRow 的父行。Gets the parent rows of a DataRow using the specified DataRelation.

public:
 cli::array <System::Data::DataRow ^> ^ GetParentRows(System::Data::DataRelation ^ relation);
public System.Data.DataRow[] GetParentRows (System.Data.DataRelation? relation);
public System.Data.DataRow[] GetParentRows (System.Data.DataRelation relation);
member this.GetParentRows : System.Data.DataRelation -> System.Data.DataRow[]
Public Function GetParentRows (relation As DataRelation) As DataRow()

参数

relation
DataRelation

要使用的 DataRelationThe DataRelation to use.

返回

DataRow[]

一个 DataRow 对象数组,或长度为零的数组。An array of DataRow objects or an array of length zero.

例外

DataRelation 不属于此行的 DataSetThe DataRelation does not belong to this row's DataSet.

该行为 nullThe row is null.

此关系的子表不是该行所属的表。The relation's child table is not the table the row belongs to.

该行不属于 DataTableThe row does not belong to a DataTable.

示例

下面的示例使用 GetParentRows 返回 DataRow 中每个子对象的子对象 DataRelation DataTableThe following example uses the GetParentRows 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 Sub GetChildRowsFromDataRelation(table As DataTable)
    Dim relation As DataRelation
    Dim arrRows() As DataRow
    Dim row As DataRow
    Dim i As Integer
    Dim column As DataColumn 
 
    For Each relation In table.ParentRelations
      For Each row In table.Rows
          arrRows = row.GetParentRows(relation)
          ' Print values of rows.
          For i = 0 To arrRows.GetUpperBound(0)
             For Each column in table.Columns
                Console.WriteLine(arrRows(i)(column.ColumnName))
             Next column
          Next i
       Next row
    Next relation
 End Sub

注解

在中 DataSet ,该数据集的所有父对象的集合 DataRelationGetParentRows 方法返回。In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

DataTable还包含 DataRelation 由属性返回的对象的集合 ParentRelationsThe DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

另请参阅

适用于

GetParentRows(String)

使用 DataRelation 的指定 RelationName 获取 DataRow 的父行。Gets the parent rows of a DataRow using the specified RelationName of a DataRelation.

public:
 cli::array <System::Data::DataRow ^> ^ GetParentRows(System::String ^ relationName);
public System.Data.DataRow[] GetParentRows (string? relationName);
public System.Data.DataRow[] GetParentRows (string relationName);
member this.GetParentRows : string -> System.Data.DataRow[]
Public Function GetParentRows (relationName As String) As DataRow()

参数

返回

DataRow[]

一个 DataRow 对象数组,或长度为零的数组。An array of DataRow objects or an array of length zero.

例外

关系和行不属于同一个表。The relation and row do not belong to the same table.

此行不属于该表。The row does not belong to the table.

注解

在中 DataSet ,该数据集的所有父对象的集合 DataRelationGetParentRows 方法返回。In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

DataTable还包含 DataRelation 由属性返回的对象的集合 ParentRelationsThe DataTable also contains a collection of DataRelation objects, returned by the ParentRelations property.

适用于

GetParentRows(String, DataRowVersion)

使用 DataRelation 的指定 RelationNameDataRowVersion 获取 DataRow 的父行。Gets the parent rows of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.

public:
 cli::array <System::Data::DataRow ^> ^ GetParentRows(System::String ^ relationName, System::Data::DataRowVersion version);
public System.Data.DataRow[] GetParentRows (string? relationName, System.Data.DataRowVersion version);
public System.Data.DataRow[] GetParentRows (string relationName, System.Data.DataRowVersion version);
member this.GetParentRows : string * System.Data.DataRowVersion -> System.Data.DataRow[]
Public Function GetParentRows (relationName As String, version As DataRowVersion) As DataRow()

参数

version
DataRowVersion

DataRowVersion 值之一,指定要获取的数据的版本。One of the DataRowVersion values specifying the version of the data to get. 可能值为 DefaultOriginalCurrentProposedPossible values are Default, Original, Current, and Proposed.

返回

DataRow[]

一个 DataRow 对象数组,或长度为零的数组。An array of DataRow objects or an array of length zero.

例外

关系和行不属于同一个表。The relation and row do not belong to the same table.

relationnullThe relation is null.

此行不属于该表。The row does not belong to the table.

该行没有请求的 DataRowVersionThe row does not have the requested DataRowVersion.

注解

在中 DataSet ,该数据集的所有父对象的集合 DataRelationGetParentRows 方法返回。In a DataSet, the collection of all parent DataRelation objects for the data set is returned by the GetParentRows method.

DataTable还包含 DataRelation 由属性返回的对象的集合 ParentRelationsThe 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.

适用于