Example #1
0
        private void InitRecords(IFilter filter)
        {
            DataViewRowState states = recordStates;

            // SQLBU 428961: Serious performance issue when creating DataView
            // this improves performance when the is no filter, like with the default view (creating after rows added)
            // we know the records are in the correct order, just append to end, duplicates not possible
            bool append = (0 == IndexFields.Length);

            records = new IndexTree(this);

            recordCount = 0;

            // SQLBU 428961: Serious performance issue when creating DataView
            // this improves performance by iterating of the index instead of computing record by index
            foreach (DataRow b in table.Rows)
            {
                int record = -1;
                if (b.oldRecord == b.newRecord)
                {
                    if ((int)(states & DataViewRowState.Unchanged) != 0)
                    {
                        record = b.oldRecord;
                    }
                }
                else if (b.oldRecord == -1)
                {
                    if ((int)(states & DataViewRowState.Added) != 0)
                    {
                        record = b.newRecord;
                    }
                }
                else if (b.newRecord == -1)
                {
                    if ((int)(states & DataViewRowState.Deleted) != 0)
                    {
                        record = b.oldRecord;
                    }
                }
                else
                {
                    if ((int)(states & DataViewRowState.ModifiedCurrent) != 0)
                    {
                        record = b.newRecord;
                    }
                    else if ((int)(states & DataViewRowState.ModifiedOriginal) != 0)
                    {
                        record = b.oldRecord;
                    }
                }
                if (record != -1 && AcceptRecord(record, filter))
                {
                    records.InsertAt(-1, record, append);
                    recordCount++;
                }
            }
        }
 private void InitRecords(IFilter filter)
 {
     DataViewRowState recordStates = this.recordStates;
     bool append = 0 == this.IndexFields.Length;
     this.records = new IndexTree(this);
     this.recordCount = 0;
     foreach (DataRow row in this.table.Rows)
     {
         int record = -1;
         if (row.oldRecord == row.newRecord)
         {
             if ((recordStates & DataViewRowState.Unchanged) != DataViewRowState.None)
             {
                 record = row.oldRecord;
             }
         }
         else if (row.oldRecord == -1)
         {
             if ((recordStates & DataViewRowState.Added) != DataViewRowState.None)
             {
                 record = row.newRecord;
             }
         }
         else if (row.newRecord == -1)
         {
             if ((recordStates & DataViewRowState.Deleted) != DataViewRowState.None)
             {
                 record = row.oldRecord;
             }
         }
         else if ((recordStates & DataViewRowState.ModifiedCurrent) != DataViewRowState.None)
         {
             record = row.newRecord;
         }
         else if ((recordStates & DataViewRowState.ModifiedOriginal) != DataViewRowState.None)
         {
             record = row.oldRecord;
         }
         if ((record != -1) && this.AcceptRecord(record, filter))
         {
             this.records.InsertAt(-1, record, append);
             this.recordCount++;
         }
     }
 }