DataRow.GetChildRows 方法
定义
重载
GetChildRows(DataRelation) |
使用指定的 DataRelation 获取此 DataRow 的子行。Gets the child rows of this DataRow using the specified DataRelation. |
GetChildRows(String) |
使用 DataRelation 的指定 RelationName 获取 DataRow 的子行。Gets the child rows of a DataRow using the specified RelationName of a DataRelation. |
GetChildRows(DataRelation, DataRowVersion) |
使用指定的 DataRelation 和 DataRowVersion 获取 DataRow 的子行。Gets the child rows of a DataRow using the specified DataRelation, and DataRowVersion. |
GetChildRows(String, DataRowVersion) |
使用 DataRelation 的指定 RelationName 和 DataRowVersion获取 DataRow 的子行。Gets the child rows of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion. |
GetChildRows(DataRelation)
使用指定的 DataRelation 获取此 DataRow 的子行。Gets the child rows of this DataRow using the specified 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。The DataRelation to use.
返回
- DataRow[]
一个 DataRow 对象数组,或长度为零的数组。An array of DataRow objects or an array of length zero.
例外
关系和行不属于同一个表。The relation and row do not belong to the same table.
关系为 null
。The relation is null
.
此行不属于该表。The row does not belong to the table.
该行没有此版本的数据。The row does not have this version of data.
示例
下面的示例使用 GetChildRows 返回 DataRow 中每个子对象的子对象 DataRelation DataTable 。The following example uses the GetChildRows 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 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 。The DataTable also contains a collection of DataRelation objects that is returned by the ChildRelations property.
另请参阅
- ChildRelations
- DataRelation
- GetParentRows(String)
- Relations
- 在 ADO.NET 中使用数据集Using DataSets in ADO.NET
适用于
GetChildRows(String)
使用 DataRelation 的指定 RelationName 获取 DataRow 的子行。Gets the child rows of a DataRow using the specified RelationName of a DataRelation.
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
要使用的 DataRelation 的 RelationName。The RelationName of the DataRelation to use.
返回
- 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.
注解
DataTable还包含 DataRelation 由属性返回的对象的集合 ChildRelations 。The DataTable also contains a collection of DataRelation objects that is returned by the ChildRelations property.
适用于
GetChildRows(DataRelation, DataRowVersion)
使用指定的 DataRelation 和 DataRowVersion 获取 DataRow 的子行。Gets the child rows of a DataRow using the specified DataRelation, and 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。The DataRelation to use.
- version
- DataRowVersion
DataRowVersion 值之一,指定要获取的数据的版本。One of the DataRowVersion values specifying the version of the data to get. 可能值为 Default
、Original
、Current
和 Proposed
。Possible values are Default
, Original
, Current
, and Proposed
.
返回
- DataRow[]
一个 DataRow 对象数组。An array of DataRow objects.
例外
关系和行不属于同一个表。The relation and row do not belong to the same table.
relation
为 null
。The relation
is null
.
此行不属于该表。The row does not belong to the table.
该行没有请求的 DataRowVersion。The row does not have the requested DataRowVersion.
示例
下面的示例使用 GetChildRows 返回 DataRow 中每个子对象的子对象 DataRelation DataTable 。The following example uses the GetChildRows to return the child DataRow objects for every child DataRelation in a DataTable. 然后打印行中具有指定版本的每一列的值。The value of each column with the specified version in the row is then printed.
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 。The DataTable also contains a collection of DataRelation objects that is returned by the ChildRelations property.
使用 HasVersion 属性来确定是否存在所 DataRowVersion 需的。Use the HasVersion property to determine whether the DataRowVersion that you want exists.
如果 Default 指定了,则使用的版本取决于调用的 RowState 行的 GetChildRows
。If Default is specified, the version that is used depends on the RowState of the row on which GetChildRows
is invoked. 如果调用的行 GetChildRows
具有 RowState
、或的,则 Modified
New
该行的 Unchanged
Current 版本用于提取其当前版本中具有匹配值的相关子行。If the row on which GetChildRows
is invoked has a RowState
of Modified
, New
, or Unchanged
, the Current version of the row is used for fetching related child rows with matching values in their Current versions. 如果调用的行的为 GetChildRows
RowState
,则该行的 Deleted
Original 版本用于提取其原始版本中具有匹配值的相关子行。If the row on which GetChildRows
is invoked has a RowState
of Deleted
, the Original version of the row is used for fetching related child rows with matching values in their original versions.
另请参阅
- ChildRelations
- DataRelation
- DataRowVersion
- GetParentRow(String)
- GetParentRows(String)
- Relations
- 在 ADO.NET 中使用数据集Using DataSets in ADO.NET
适用于
GetChildRows(String, DataRowVersion)
使用 DataRelation 的指定 RelationName 和 DataRowVersion获取 DataRow 的子行。Gets the child rows of a DataRow using the specified RelationName of a DataRelation, and DataRowVersion.
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
要使用的 DataRelation 的 RelationName。The RelationName of the DataRelation to use.
- version
- DataRowVersion
DataRowVersion 值之一,指定要获取的数据的版本。One of the DataRowVersion values specifying the version of the data to get. 可能值为 Default
、Original
、Current
和 Proposed
。Possible 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.
relation
为 null
。The relation
is null
.
此行不属于该表。The row does not belong to the table.
该行没有请求的 DataRowVersion。The row does not have the requested DataRowVersion.
注解
DataTable还包含 DataRelation 由属性返回的对象的集合 ChildRelations 。The DataTable also contains a collection of DataRelation objects that is returned by the ChildRelations property.
使用 HasVersion 属性来确定是否存在所 DataRowVersion 需的。Use the HasVersion property to determine whether the DataRowVersion that you want exists.
如果 Default 指定了,则使用的版本取决于调用的 RowState 行的 GetChildRows
。If Default is specified, the version that is used depends on the RowState of the row on which GetChildRows
is invoked. 如果调用的行 GetChildRows
具有 RowState
、或的,则 Modified
New
该行的 Unchanged
Current 版本用于提取其当前版本中具有匹配值的相关子行。If the row on which GetChildRows
is invoked has a RowState
of Modified
, New
, or Unchanged
, the Current version of the row is used for fetching related child rows with matching values in their Current versions. 如果调用的行的为 GetChildRows
RowState
,则该行的 Deleted
Original 版本用于提取其原始版本中具有匹配值的相关子行。If the row on which GetChildRows
is invoked has a RowState
of Deleted
, the Original version of the row is used for fetching related child rows with matching values in their original versions.