DataRow.GetChildRows メソッド

定義

DataRow の子行を取得します。

オーバーロード

GetChildRows(DataRelation)

指定した DataRow を使用して、この DataRelation の子行を取得します。

GetChildRows(String)

DataRow の指定した RelationName を使用して、DataRelation の子行を取得します。

GetChildRows(DataRelation, DataRowVersion)

指定した DataRowDataRelation を使用して、DataRowVersion の子行を取得します。

GetChildRows(String, DataRowVersion)

DataRow の指定した RelationNameDataRelation を使用して、DataRowVersion の子行を取得します。

GetChildRows(DataRelation)

指定した 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 オブジェクトの配列、または長さ 0 の配列。

例外

リレーションシップと行が同じテーブルに属していません。

リレーションシップが null です。

行がこのテーブルに属していません。

このバージョンのデータが行にありません。

次の例では、 を GetChildRows 使用して、 内のすべての子 DataRow の子 DataRelation オブジェクトを DataTable返します。 その後、行の各列の値が出力されます。

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には、 プロパティによってChildRelations返される オブジェクトのDataRelationコレクションも含まれています。

こちらもご覧ください

適用対象

GetChildRows(String)

DataRow の指定した RelationName を使用して、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

使用する RelationNameDataRelation

戻り値

DataRow オブジェクトの配列、または長さ 0 の配列。

例外

リレーションシップと行が同じテーブルに属していません。

行がこのテーブルに属していません。

注釈

DataTableには、 プロパティによってChildRelations返される オブジェクトのDataRelationコレクションも含まれています。

適用対象

GetChildRows(DataRelation, DataRowVersion)

指定した DataRowDataRelation を使用して、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 値の 1 つ。 指定できる値は、DefaultOriginalCurrent、および Proposed です。

戻り値

DataRow オブジェクトの配列。

例外

リレーションシップと行が同じテーブルに属していません。

relationnull です。

行がこのテーブルに属していません。

要求された DataRowVersion が行にありません。

次の例では、 を GetChildRows 使用して、 内のすべての子 DataRow の子 DataRelation オブジェクトを DataTable返します。 その後、行に指定されたバージョンの各列の値が出力されます。

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には、 プロパティによってChildRelations返される オブジェクトのDataRelationコレクションも含まれています。

プロパティを HasVersion 使用して、目的の が DataRowVersion 存在するかどうかを確認します。

が指定されている場合 Default 、使用されるバージョンは、 RowState 呼び出される行の によって GetChildRows 異なります。 呼び出される行の GetChildRows が 、、Newまたは UnchangedCurrent の場合、RowState行のModifiedバージョンは、現在のバージョンの値が一致する関連する子行をフェッチするために使用されます。 呼び出される行に GetChildRowsDeletedOriginal がある場合、RowState行のバージョンは、元のバージョンの値が一致する関連する子行をフェッチするために使用されます。

こちらもご覧ください

適用対象

GetChildRows(String, DataRowVersion)

DataRow の指定した RelationNameDataRelation を使用して、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

使用する RelationNameDataRelation

version
DataRowVersion

取得するデータのバージョンを指定する DataRowVersion 値の 1 つ。 指定できる値は、DefaultOriginalCurrent、および Proposed です。

戻り値

DataRow オブジェクトの配列、または長さ 0 の配列。

例外

リレーションシップと行が同じテーブルに属していません。

relationnull です。

行がこのテーブルに属していません。

要求された DataRowVersion が行にありません。

注釈

DataTableには、 プロパティによってChildRelations返される オブジェクトのDataRelationコレクションも含まれています。

プロパティを HasVersion 使用して、目的の が DataRowVersion 存在するかどうかを確認します。

が指定されている場合 Default 、使用されるバージョンは、 RowState 呼び出される行の によって GetChildRows 異なります。 呼び出される行の GetChildRows が 、、Newまたは UnchangedCurrent の場合、RowState行のModifiedバージョンは、現在のバージョンの値が一致する関連する子行をフェッチするために使用されます。 呼び出される行に GetChildRowsDeletedOriginal がある場合、RowState行のバージョンは、元のバージョンの値が一致する関連する子行をフェッチするために使用されます。

適用対象