DataRow.GetChildRows 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得子節點 DataRow列。
多載
| 名稱 | Description |
|---|---|
| GetChildRows(DataRelation) |
利用指定的 DataRelation取得此子DataRow列。 |
| GetChildRows(String) |
利用指定的 RelationNameDataRelation取得 的DataRow子列。 |
| GetChildRows(DataRelation, DataRowVersion) |
利用指定的 DataRelation、 和 DataRowVersion取得 a DataRow 的子列。 |
| GetChildRows(String, DataRowVersion) |
利用指定RelationName的 DataRelation、 DataRowVersion和 取得 的DataRow子列。 |
GetChildRows(DataRelation)
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
利用指定的 DataRelation取得此子DataRow列。
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。
該排不屬於桌子。
該列沒有這個版本的資料。
範例
以下範例使用 來GetChildRows回傳 中每個子節點DataRelationDataTable的子DataRow物件。 接著列印該列中每一欄的值。
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)
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
利用指定的 RelationNameDataRelation取得 的DataRow子列。
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)
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
利用指定的 DataRelation、 和 DataRowVersion取得 a DataRow 的子列。
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。
該排不屬於桌子。
該列沒有被要求 DataRowVersion的 。
範例
以下範例使用 來GetChildRows回傳 中每個子節點DataRelationDataTable的子DataRow物件。 接著列印每列指定版本欄位的值。
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指定 ,所使用的版本取決於所呼叫的列 GetChildRows 。RowState 如果被呼叫的列 GetChildRows 有 RowState 、 Modified、 New或 Unchanged, Current 則該列的版本用於擷取與目前版本值相符的相關子列。 如果被呼叫的列 GetChildRows 有 RowState 的 , Deleted則 Original 該列的版本用於擷取與原始版本值相符的相關子列。
另請參閱
- ChildRelations
- DataRelation
- DataRowVersion
- GetParentRow(String)
- GetParentRows(String)
- Relations
- 在 ADO.NET 中使用 DataSets
適用於
GetChildRows(String, DataRowVersion)
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
- 來源:
- DataRow.cs
利用指定RelationName的 DataRelation、 DataRowVersion和 取得 的DataRow子列。
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 ,或長度為零的陣列。
例外狀況
關係與列不屬於同一張表格。
該排不屬於桌子。
該列沒有被要求 DataRowVersion的 。
備註
同時 DataTable 也包含一組 DataRelation 由屬性 ChildRelations 回傳的物件集合。
利用該 HasVersion 房產判斷你想要的 DataRowVersion 房產是否存在。
若Default指定 ,所使用的版本取決於所呼叫的列 GetChildRows 。RowState 如果被呼叫的列 GetChildRows 有 RowState 、 Modified、 New或 Unchanged, Current 則該列的版本用於擷取與目前版本值相符的相關子列。 如果被呼叫的列 GetChildRows 有 RowState 的 , Deleted則 Original 該列的版本用於擷取與原始版本值相符的相關子列。