System.Data.DataTable.SuspendIndexEvents C# (CSharp) Method

SuspendIndexEvents() private method

private SuspendIndexEvents ( ) : void
return void
        internal void SuspendIndexEvents()
        {
            DataCommonEventSource.Log.Trace("<ds.DataTable.SuspendIndexEvents|Info> {0}, {1}", ObjectID, _suspendIndexEvents);
            _suspendIndexEvents++;
        }

Usage Example

Example #1
0
        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       = default(DataKey);
                dst.SuspendIndexEvents();
                try
                {
                    if (!wasEmpty && dst._primaryKey != null)
                    {
                        key = GetSrcKey(src, dst);
                        if (key.HasValue)
                        {
                            ndxSearch = dst._primaryKey.Key.GetSortIndex(DataViewRowState.OriginalRows | DataViewRowState.Added);
                        }
                    }

                    // this improves performance by iterating over the rows instead of computing their position
                    foreach (DataRow sourceRow in src.Rows)
                    {
                        DataRow?targetRow = null;
                        if (ndxSearch != null)
                        {
                            targetRow = dst.FindMergeTarget(sourceRow, key, ndxSearch);
                        }
                        dst.MergeRow(sourceRow, targetRow, _preserveChanges, ndxSearch);
                    }
                }
                finally
                {
                    dst.RestoreIndexEvents(true);
                }
            }
            MergeExtendedProperties(src.ExtendedProperties, dst.ExtendedProperties);
        }
All Usage Examples Of System.Data.DataTable::SuspendIndexEvents
DataTable