public void SetParentRow(DataRow parentRow, DataRelation relation)
{
if (relation == null)
{
SetParentRow(parentRow);
return;
}
if (parentRow == null)
{
SetParentRowToDBNull(relation);
return;
}
if (_table.DataSet != parentRow._table.DataSet)
{
throw ExceptionBuilder.ParentRowNotInTheDataSet();
}
if (relation.ChildKey.Table != _table)
{
throw ExceptionBuilder.SetParentRowTableMismatch(relation.ChildKey.Table.TableName, _table.TableName);
}
if (relation.ParentKey.Table != parentRow._table)
{
throw ExceptionBuilder.SetParentRowTableMismatch(relation.ParentKey.Table.TableName, parentRow._table.TableName);
}
object[] parentKeyValues = parentRow.GetKeyValues(relation.ParentKey);
SetKeyValues(relation.ChildKey, parentKeyValues);
}