语言

DataRow.GetChildRows 方法

定义

获取一个 DataRow. 的子行。

重载

名称 说明
GetChildRows(DataRelation)

使用指定的DataRow值获取此DataRelation项的子行。

GetChildRows(String)

获取使用指定DataRow项的RelationNameDataRelation子行。

GetChildRows(DataRelation, DataRowVersion)

获取使用指定项的DataRow子行,以及 DataRelation。DataRowVersion

GetChildRows(String, DataRowVersion)

获取使用 /a0> 和 /a> 的指定项的子行。

GetChildRows(DataRelation)

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

使用指定的DataRow值获取此DataRelation项的子行。

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

参数

relation
DataRelation

要使用的 DataRelation 。

返回

对象的数组 DataRow 或长度为零的数组。

例外

关系和行不属于同一个表。

关系是 null。

该行不属于该表。

该行没有此版本的数据。

示例

以下示例使用 > 返回每个子项的子对象。 然后打印行中每列的值。

private void GetChildRowsFromDataRelation(DataTable table)
{
    DataRow[] arrRows;
    foreach(DataRelation relation in table.ChildRelations)
    {
        foreach(DataRow row in table.Rows)
        {
            arrRows = row.GetChildRows(relation);
            // Print values of rows.
            for(int i = 0; i < arrRows.Length; i++)
            {
                foreach(DataColumn column in table.Columns)
                {
                    Console.WriteLine(arrRows[i][column]);
                }
            }
        }
    }
}
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.ChildRelations
      For Each row In table.Rows
          arrRows = row.GetChildRows(relation)
          ' Print values of rows.
          For i = 0 To arrRows.GetUpperBound(0)
             For Each column in table.Columns
                Console.WriteLine(arrRows(i)(column))
             Next column
          Next i
       Next row
    Next relation
 End Sub

注解

它还DataTable包含属性返回DataRelation的对象集合ChildRelations。

另请参阅

适用于

GetChildRows(String)

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

获取使用指定DataRow项的RelationNameDataRelation子行。

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

参数

relationName
String

RelationName DataRelation要使用的项。

返回

对象的数组 DataRow 或长度为零的数组。

例外

关系和行不属于同一个表。

该行不属于该表。

注解

它还DataTable包含属性返回DataRelation的对象集合ChildRelations。

适用于

GetChildRows(DataRelation, DataRowVersion)

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

获取使用指定项的DataRow子行,以及 DataRelation。DataRowVersion

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

参数

relation
DataRelation

要使用的 DataRelation 。

version
DataRowVersion

DataRowVersion指定要获取的数据版本的值之一。 可能值为 Default、Original、Current 和 Proposed。

返回

一个 DataRow 对象数组。

例外

关系和行不属于同一个表。

relation 是 null。

该行不属于该表。

示例

以下示例使用 > 返回每个子项的子对象。 然后打印行中具有指定版本的每列的值。

private void GetChildRowsFromDataRelation(DataTable table )
{
    DataRow[] arrRows;
    foreach(DataRelation relation in table.ChildRelations)
    {
        foreach(DataRow row in table.Rows)
        {
            arrRows = row.GetChildRows(relation,
                DataRowVersion.Proposed);
            // Print values of rows.
            for(int i = 0; i < arrRows.Length; i++)
            {
                foreach(DataColumn column in table.Columns)
                {
                    Console.WriteLine(arrRows[i][column]);
                }
            }
        }
    }
}
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.ChildRelations
      For Each row In table.Rows
          arrRows = row.GetChildRows(relation, _
                DataRowVersion.Proposed)
          ' Print values of rows.
          For i = 0 To arrRows.GetUpperBound(0)
             For Each column in table.Columns
                Console.WriteLine(arrRows(i)(column))
             Next column
          Next i
       Next row
    Next relation
End Sub

注解

它还DataTable包含属性返回DataRelation的对象集合ChildRelations。

使用属性 HasVersion 确定 DataRowVersion 所需的是否存在。

如果 Default 已指定,则所使用的版本取决于 RowState 调用的 GetChildRows 行。 如果调用的GetChildRows行具有RowState其ModifiedNew当前版本中匹配值的相关子行,则UnchangedCurrent使用该行的版本或该行的版本来提取具有匹配值的子行。 如果调用的GetChildRows行有一个RowStateDeleted,则Original行的版本用于提取原始版本中具有匹配值的相关子行。

另请参阅

适用于

GetChildRows(String, DataRowVersion)

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

获取使用 /a0> 和 /a> 的指定项的子行。

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

参数

relationName
String

RelationName DataRelation要使用的项。

version
DataRowVersion

DataRowVersion指定要获取的数据版本的值之一。 可能值为 Default、Original、Current 和 Proposed。

返回

对象的数组 DataRow 或长度为零的数组。

例外

关系和行不属于同一个表。

该行不属于该表。

注解

它还DataTable包含属性返回DataRelation的对象集合ChildRelations。

使用属性 HasVersion 确定 DataRowVersion 所需的是否存在。

如果 Default 已指定,则所使用的版本取决于 RowState 调用的 GetChildRows 行。 如果调用的GetChildRows行具有RowState其ModifiedNew当前版本中匹配值的相关子行,则UnchangedCurrent使用该行的版本或该行的版本来提取具有匹配值的子行。 如果调用的GetChildRows行有一个RowStateDeleted,则Original行的版本用于提取原始版本中具有匹配值的相关子行。

适用于