DataRelation Members

Overview

The DataRelation class is the concrete implementation of IDataRelation in the PocoDataSet.Data assembly. It represents a logical relationship between two tables in a data set, typically modeling a parent/child association using one or more key columns.

A relation identifies the parent and child table names and the corresponding lists of column names that form the relationship. Relations can be used by higher-level code to build hierarchical views, such as master/detail screens or tree-like navigation.

Namespace and Assembly

Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll

Declaration

public class DataRelation : IDataRelation
{
    public List<string> ChildColumnNames { get; set; }
    public string ChildTableName { get; set; }
    public string? DisplayField { get; set; }
    public List<string> ParentColumnNames { get; set; }
    public string ParentTableName { get; set; }
    public string RelationName { get; set; }
}

Property Notes

Usage Example

// 1. Create an empty data set
IDataSet dataSet = DataSetFactory.CreateDataSet();

// 2. Create Department and Employee tables
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);

IDataTable employeeDataTable = dataSet.AddNewTable("Employee");
employeeDataTable.AddColumn("Id", DataTypeNames.INT32);
employeeDataTable.AddColumn("DepartmentId", DataTypeNames.INT32);
employeeDataTable.AddColumn("Name", DataTypeNames.STRING);

// 3. Create a relation between Department and Employee tables
IDataRelation dataRelation = dataSet.AddRelation("Department_Employees", "Department", "Id", "Employee", "DepartmentId");
dataRelation.DisplayField = "Name"; // Optional display field for UI

 

Table of Content POCO DataSet POCO DataSet Types

 


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.