score:3

Accepted answer

You don't need LINQ for this.

Instead, you can check masterRow.GetChildRows("RelationName").Length.

EDIT: You should use a DataRelation.

If you really don't want to, you can check

childTable.AsEnumerable().Any(dr => dr["ParentIdColumn"] == someValue)

EDIT: To check for multiple parents:

var parentKeys = parentRows.Select(dr => dr["id"]).ToList();

if (childTable.AsEnumerable().Any(dr => parentKeys.Contains(["ParentIdColumn"])))

Related Articles