GetChildRows Method
The GetChildRows method navigates a relation from a parent row to its child rows.
It uses the relation metadata stored in IDataSet.Relations and matches child rows based on key column values.
/// <summary>
/// Enumerates child rows for a given parent row and relation.
/// By default, Deleted child rows are not returned.
/// </summary>
/// <param name="dataSet">Data set</param>
/// <param name="relationName">Relation name</param>
/// <param name="parentRow">Parent row</param>
/// <param name="includeDeletedChildren">If true, Deleted child rows are included</param>
/// <returns>List of child rows (empty if none)</returns>
public static List<IDataRow> GetChildRows(this IDataSet? dataSet, string? relationName, IDataRow? parentRow, bool includeDeletedChildren = false)
Namespace: PocoDataSet.Extensions
Assembly: PocoDataSet.Extensions.dll
dataSet or parentRow is null.relationName is null, the navigation helper attempts to resolve a relation based on table names.Deleted state are excluded. Set includeDeletedChildren to include them.
IDataSet dataSet = DataSetFactory.CreateDataSet();
IDataTable customers = dataSet.AddNewTable("Customers");
customers.AddColumn("Id", DataTypeNames.INT32, false, true);
customers.AddColumn("Name", DataTypeNames.STRING);
IDataTable orders = dataSet.AddNewTable("Orders");
orders.AddColumn("OrderId", DataTypeNames.INT32, false, true);
orders.AddColumn("CustomerId", DataTypeNames.INT32, false, false);
orders.AddColumn("Status", DataTypeNames.STRING);
dataSet.AddRelation(
"CustomerOrders",
"Customers",
new List<string> { "Id" },
"Orders",
new List<string> { "CustomerId" });
IDataRow c1 = customers.AddNewRow();
c1["Id"] = 1;
c1["Name"] = "Acme";
customers.AcceptChanges();
IDataRow o10 = orders.AddNewRow();
o10["OrderId"] = 10;
o10["CustomerId"] = 1;
o10["Status"] = "Open";
orders.AcceptChanges();
IDataRow o11 = orders.AddNewRow();
o11["OrderId"] = 11;
o11["CustomerId"] = 1;
o11["Status"] = "Closed";
orders.AcceptChanges();
// Navigate: parent -> children
List<IDataRow> customerOrders = dataSet.GetChildRows("CustomerOrders", c1);
// customerOrders contains o10 and o11
relationName when you have more than one relation between the same tables.Table of Content POCO DataSet DataSet 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.