ComponentOne ADO.NET DataExtender
C1DataView Relations / Specifying a Parent View
In This Topic
    Specifying a Parent View
    In This Topic

    Two views can be tied by a master-detail relationship only if one of the base DataTables, which has the view on which the definition is based, of the master view has a DataRelation defined in the underlying dataset which connects it to some base DataTable of the detail view.

    When you specify a parent view for a certain detail view in the Add View dialog box of the C1ViewSetDesignerForm, you can specify this DataRelation explicitly.

    If you choose not to specify it, the C1DataViewSet automatically selects some DataRelation which can connect those views. Namely, this DataRelation determines the fields which are used to filter out detail rows for a current master row.

    There are cases when more than one DataRelation can connect views, for example, suppose that we have views with the following definitions:

    MasterView SELECT * Customers JOIN Orders

    DetailView SELECT * Orders JOIN [Order Details]

    These views can be tied based on two DataRelation "Customers -> Orders" (Orders from the DetailView here) and "Orders -> Order Details" (Orders from the MasterView here).

    In this case it's reasonable to define a base DataRelation explicitly because C1DataViewSet could select a DataRelation other than the one you are supposed to use.

    You can specify a parent view in the Add View dialog box when you add a C1DataView. To do this:

    1. Add a view to your C1DataViewSet and specify the definition in the Add View dialog box.
    2. From the left pane select a child view, and under Select a parent view, select one of the possible parent view tables from the list.

    You can access the Set Parent View dialog box from the C1ViewSetDesignerForm by clicking the Set Parent View button.


    Another complex case when more than one DataRelation connects views is when some or both of the views involved in a master-detail relationship reference the same DataTable more than once (in this case the tables' occurrences in a definition statement are differentiated by their aliases). If the base DataRelation corresponds to such a DataTable, you should have the ability to specify which occurrence of the DataTable must be used (that is, rows of what table alias participate in the relationship). You can do this by explicitly defining an involved DataTable alias in the Set Parent View dialog box. To do this:

    1. Click the Set Parent View button. The Set Parent View dialog box opens.
    2. Select a Base DataRelation that corresponds to the DataTable from the drop-down box.
    3. Specify the Parent DataTable alias and Child DataTable alias.
    Note: Set any of the Parent relation details drop-down lists to <auto detected> if you want the C1ViewSetDesignerForm to automatically detect them for you.
    See Also