DataRelation Members

Data relation defines how two tables, parent and child, are related to each other in a data set. It specifies which columns from the parent table match with which columns from the child table. This information is essential for navigating between related rows, enforcing referential integrity, and enabling features like cascading deletes or updates.

Columns that participate in a relation are usually key columns. The parent columns typically hold primary key values, while the child columns hold foreign key values that reference the parent rows.

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; }
}

Properties

Contract: IDataRelation interface in PocoDataSet.IData library
Implementation: DataRelation class in PocoDataSet.Data library

All properties are required to define a relation, except for DisplayField, which is optional and intended for presentation scenarios.

Usage Example

Single-column relation: Department.Id -> Employee.DepartmentId

IDataRelation relation = new DataRelation();
relation.RelationName = "Department_Employee";
relation.ParentTableName = "Department";
relation.ParentColumnNames = new List<string> { "Id" };
relation.ChildTableName = "Employee";
relation.ChildColumnNames = new List<string> { "DepartmentId" };

Composite relation: Shipment(OrderId, CompanyId) -> ShipmentLine(OrderId, CompanyId)

IDataRelation compositeRelation = new DataRelation();
compositeRelation.RelationName = "Shipment_ShipmentLine";
compositeRelation.ParentTableName = "Shipment";
compositeRelation.ParentColumnNames = new List<string> { "OrderId", "CompanyId" };
compositeRelation.ChildTableName = "ShipmentLine";
compositeRelation.ChildColumnNames = new List<string> { "OrderId", "CompanyId" };

Table of Content POCO DataSet API References 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.