private void MergeTable(DataTable src, DataTable dst)
{
int rowsCount = src.Rows.Count;
bool wasEmpty = dst.Rows.Count == 0;
if (0 < rowsCount)
{
Index ndxSearch = null;
DataKey key = null;
ArrayList saveIndexes = dst.LiveIndexes;
dst.indexes = new ArrayList();
if (!wasEmpty && dst.primaryKey != null)
{
key = GetSrcKey(src, dst);
if (key != null)
{
ndxSearch = dst.primaryKey.Key.GetSortIndex(DataViewRowState.OriginalRows | DataViewRowState.Added);
}
}
for (int i = 0; i < rowsCount; i++)
{
DataRow sourceRow = src.Rows[i];
DataRow targetRow = null;
if (ndxSearch != null)
{
targetRow = dst.FindMergeTarget(sourceRow, key, ndxSearch);
}
dst.MergeRow(sourceRow, targetRow, preserveChanges, ndxSearch);
}
dst.indexes = saveIndexes;
dst.ResetIndexes();
}
MergeExtendedProperties(src.ExtendedProperties, dst.ExtendedProperties);
}