NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataTable.ChildRelations

Gets the collection of child relations for this DataTable.

[Visual Basic]
Public ReadOnly Property ChildRelations As RelationsCollection
[C#]
public RelationsCollection ChildRelations {get;}
[C++]
public: __property RelationsCollection* get_ChildRelations();
[JScript]
public function get ChildRelations() : RelationsCollection;

Property Value

A RelationsCollection that contains the child relations for the table.

Remarks

A DataRelation defines the relationship between two tables. Typically, two tables are linked through a single field that contains the same data. For example, a table which contains address data may have a single field containing codes that represent countries. A second table that contains country data will have a single field that contains the code that identifies the country, and it is this code which is inserted into the corresponding field in the first table. A DataRelation, then, contains at least four pieces of information: (1) the name of the first table, (2) the column name in the first table, (3) the name of the second table, and (4) the column name in the second table.

Example [Visual Basic]

The following example uses the ChildRelations property to return each child DataRelation in a DataTable. Each relation is then used as an argument in the GetChildRows method of the DataRow to return an array of rows. The value of each column in the row is then printed.

[Visual Basic]

Private Sub GetChildRowsFromDataRelation(myTable As DataTable)
   Dim dr As DataRelation
   Dim arrRows() As DataRow
   Dim r As DataRow
   Dim i As Integer
   Dim dc As DataColumn 

   For Each dr In myTable.ChildRelations
     For Each r In myTable.Rows
         arrRows = r.GetChildRows(dr)
         ' Print values of rows.
         For i = 0 To UBound(arrRows)
For Each dc in myTable.Columns
   Console.WriteLine(arrRows(i)(dc.ColumnName))
Next dc
         Next i
      Next r
   Next dr
End Sub

See Also

DataTable Class | DataTable Members | System.Data Namespace | ParentRelations | DataRelation | GetParentRows | GetChildRows | CreateChildView