internal DataRelation Clone(DataSet destination)
{
DataCommonEventSource.Log.Trace("<ds.DataRelation.Clone|INFO> {0}, destination={1}", ObjectID, (destination != null) ? destination.ObjectID : 0);
DataTable parent = destination.Tables[ParentTable.TableName, ParentTable.Namespace];
DataTable child = destination.Tables[ChildTable.TableName, ChildTable.Namespace];
int keyLength = _parentKey.ColumnsReference.Length;
DataColumn[] parentColumns = new DataColumn[keyLength];
DataColumn[] childColumns = new DataColumn[keyLength];
for (int i = 0; i < keyLength; i++)
{
parentColumns[i] = parent.Columns[ParentKey.ColumnsReference[i].ColumnName];
childColumns[i] = child.Columns[ChildKey.ColumnsReference[i].ColumnName];
}
DataRelation clone = new DataRelation(_relationName, parentColumns, childColumns, false);
clone.CheckMultipleNested = false; // disable the check in clone as it is already created
clone.Nested = Nested;
clone.CheckMultipleNested = true; // enable the check
// ...Extended Properties
if (_extendedProperties != null)
{
foreach (object key in _extendedProperties.Keys)
{
clone.ExtendedProperties[key] = _extendedProperties[key];
}
}
return clone;
}