Relations Property

Overview

Gets the list of relations from the underlying POCO dataset. Relations define parent / child navigation and are typically used for master-detail UI scenarios.

Declaration

/// <summary>
/// Gets relations
/// IObservableDataSet interface implementation
/// </summary>
public List<IDataRelation> Relations
{
    get
    {
        return _innerDataSet.Relations;
    }
}

Namespace and Assembly

Namespace: PocoDataSet.ObservableData
Assembly: PocoDataSet.ObservableData.dll

Usage Example

// 1. Create observable data set
IObservableDataSet observableDataSet = new ObservableDataSet();

// 2. Add parent observable data table Department
IObservableDataTable department = observableDataSet.AddNewTable("Department");
department.AddColumn("Id", DataTypeNames.INT32, isPrimaryKey: true);
department.AddColumn("Name", DataTypeNames.STRING);

// 3. Add child observable data table Employee IObservableDataTable employee = observableDataSet.AddNewTable("Employee");
employee.AddColumn("Id", DataTypeNames.INT32, isPrimaryKey: true);
employee.AddColumn("DepartmentId", DataTypeNames.INT32);
employee.AddColumn("Name", DataTypeNames.STRING);

// 4. Define a relation at POCO level (then UI can navigate)
observableDataSet.InnerDataSet.AddRelation(
    "Department_Employee",
    parentTableName: "Department",
    parentColumnName: "Id",
    childTableName: "Employee",
    childColumnName: "DepartmentId");

// 5. Observe the number of data relations in data set is changed
Console.WriteLine("Relations count: " + observableDataSet.Relations.Count);

 

Table of Content POCO DataSet API References ObservablePOCO DataSet Types ObservableDataSet Members

 


Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness or suitability of the information and are not responsible for any damages resulting from its use.