throw new ArgumentNullException("targetSet");
if(sourceSet == null)
throw new ArgumentNullException("sourceSet");
+ if (sourceSet == targetSet)
+ return;
bool prevEC = targetSet.EnforceConstraints;
targetSet.EnforceConstraints = false;
throw new ArgumentNullException("targetSet");
if(sourceTable == null)
throw new ArgumentNullException("sourceTable");
+ if (sourceTable.DataSet == targetSet)
+ return;
bool savedEnfoceConstraints = targetSet.EnforceConstraints;
targetSet.EnforceConstraints = false;
throw new ArgumentNullException("targetTable");
if(sourceTable == null)
throw new ArgumentNullException("sourceTable");
+ if (sourceTable == targetTable)
+ return;
bool savedEnforceConstraints = targetTable.EnforceConstraints;
targetTable.EnforceConstraints = false;
// merge a row into a target table.
private static void MergeRow(DataTable targetTable, DataRow row, bool preserveChanges)
{
- DataColumnCollection columns = row.Table.Columns;
DataColumn[] primaryKeys = targetTable.PrimaryKey;
DataRow targetRow = null;
DataRowVersion version = DataRowVersion.Default;
if (targetRow == null)
{
DataRow newRow = targetTable.NewNotInitializedRow();
- row.CopyValuesToRow(newRow);
+ // Don't check for ReadOnly, when cloning data to new uninitialized row.
+ row.CopyValuesToRow(newRow, false);
targetTable.Rows.AddInternal (newRow);
}
// row exists in target table, and presere changes is false -
DataColumn[] childColumns = ResolveColumns (targetSet.Tables [relation.ChildTable.TableName],
relation.ChildColumns);
targetRelation = targetSet.Relations.Add (relation.RelationName, parentColumns,
- childColumns, false);
+ childColumns, relation.createConstraints);
targetRelation.Nested = relation.Nested;
} else if (!CompareColumnArrays (relation.ParentColumns, targetRelation.ParentColumns) ||
!CompareColumnArrays (relation.ChildColumns, targetRelation.ChildColumns)) {