当前位置: 首页>>代码示例>>C#>>正文


C# DataRow.CheckInTable方法代码示例

本文整理汇总了C#中System.Data.DataRow.CheckInTable方法的典型用法代码示例。如果您正苦于以下问题:C# DataRow.CheckInTable方法的具体用法?C# DataRow.CheckInTable怎么用?C# DataRow.CheckInTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataRow的用法示例。


在下文中一共展示了DataRow.CheckInTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetOldRecord

        // this is the event workhorse... it will throw the changing/changed events
        // and update the indexes.
        internal void SetOldRecord(DataRow row, int proposedRecord) {
            if (!inDataLoad) {
                row.CheckInTable();
                CheckNotModifying(row);
            }

            if (proposedRecord == row.oldRecord) {
                return;
            }

            int originalRecord = row.oldRecord; // cache old record after potential RowChanging event
            try {
                // Check whether we need to update indexes
                if (LiveIndexes.Count != 0) {

                    // Dev10 bug #463087: DataTable internal index is currupted: '5'
                    if ((-1 == originalRecord) && (-1 != proposedRecord) && (-1 != row.newRecord) && (proposedRecord != row.newRecord)) {
                        // the transition from DataRowState.Added -> DataRowState.Modified
                        // with same current record but new original record
                        // needs to raise an ItemChanged or ItemMoved instead of ItemAdded in the ListChanged event.
                        // for indexes/views listening for both DataViewRowState.Added | DataViewRowState.ModifiedOriginal
                        originalRecord = row.newRecord;
                    }

                    DataViewRowState originalRecordStatePre = row.GetRecordState(originalRecord);
                    DataViewRowState proposedRecordStatePre = row.GetRecordState(proposedRecord);

                    row.oldRecord = proposedRecord;
                    if (proposedRecord != -1)
                        this.recordManager[proposedRecord] = row;

                    DataViewRowState originalRecordStatePost = row.GetRecordState(originalRecord);
                    DataViewRowState proposedRecordStatePost = row.GetRecordState(proposedRecord);

                    RecordStateChanged(originalRecord, originalRecordStatePre, originalRecordStatePost,
                                       proposedRecord, proposedRecordStatePre, proposedRecordStatePost);
                }
                else {
                    row.oldRecord = proposedRecord;
                    if (proposedRecord != -1)
                        this.recordManager[proposedRecord] = row;
                }
            }
            finally {
                if ((originalRecord != -1) && (originalRecord != row.tempRecord) &&
                    (originalRecord != row.oldRecord) && (originalRecord != row.newRecord)) {

                    FreeRecord(ref originalRecord);
                }
                // else during an event 'row.AcceptChanges(); row.BeginEdit(); row.EndEdit();'

                if (row.RowState == DataRowState.Detached && row.rowID != -1) {
                    RemoveRow(row, false);
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:58,代码来源:DataTable.cs

示例2: SetOldRecord

 internal void SetOldRecord(DataRow row, int proposedRecord)
 {
     if (!this.inDataLoad)
     {
         row.CheckInTable();
         this.CheckNotModifying(row);
     }
     if (proposedRecord != row.oldRecord)
     {
         int oldRecord = row.oldRecord;
         try
         {
             if (this.LiveIndexes.Count != 0)
             {
                 if (((-1 == oldRecord) && (-1 != proposedRecord)) && ((-1 != row.newRecord) && (proposedRecord != row.newRecord)))
                 {
                     oldRecord = row.newRecord;
                 }
                 DataViewRowState recordState = row.GetRecordState(oldRecord);
                 DataViewRowState state3 = row.GetRecordState(proposedRecord);
                 row.oldRecord = proposedRecord;
                 if (proposedRecord != -1)
                 {
                     this.recordManager[proposedRecord] = row;
                 }
                 DataViewRowState state2 = row.GetRecordState(oldRecord);
                 DataViewRowState state = row.GetRecordState(proposedRecord);
                 this.RecordStateChanged(oldRecord, recordState, state2, proposedRecord, state3, state);
             }
             else
             {
                 row.oldRecord = proposedRecord;
                 if (proposedRecord != -1)
                 {
                     this.recordManager[proposedRecord] = row;
                 }
             }
         }
         finally
         {
             if (((oldRecord != -1) && (oldRecord != row.tempRecord)) && ((oldRecord != row.oldRecord) && (oldRecord != row.newRecord)))
             {
                 this.FreeRecord(ref oldRecord);
             }
             if ((row.RowState == DataRowState.Detached) && (row.rowID != -1L))
             {
                 this.RemoveRow(row, false);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:51,代码来源:DataTable.cs

示例3: SetNewRecordWorker

        private void SetNewRecordWorker(DataRow row, int proposedRecord, DataRowAction action, bool isInMerge, bool suppressEnsurePropertyChanged,
            int position, bool fireEvent, out Exception deferredException) {

            // this is the event workhorse... it will throw the changing/changed events
            // and update the indexes. Used by change, add, delete, revert.

            // order of execution is as follows
            //
            // 1) set temp record
            // 2) Check constraints for non-expression columns
            // 3) Raise RowChanging/RowDeleting with temp record
            // 4) set the new record in storage
            // 5) Update indexes with recordStateChanges - this will fire ListChanged & PropertyChanged events on associated views
            // 6) Evaluate all Expressions (exceptions are deferred)- this will fire ListChanged & PropertyChanged events on associated views
            // 7) Raise RowChanged/ RowDeleted
            // 8) Check constraints for expression columns

            Debug.Assert(row != null, "Row can't be null.");
            deferredException = null;
            
            if (row.tempRecord != proposedRecord) {
                // $HACK: for performance reasons, EndUpdate calls SetNewRecord with tempRecord == proposedRecord
                if (!inDataLoad) {
                    row.CheckInTable();
                    CheckNotModifying(row);
                }
                if (proposedRecord == row.newRecord) {
                    if (isInMerge) {
                        Debug.Assert(fireEvent, "SetNewRecord is called with wrong parameter");
                        RaiseRowChanged(null, row, action);
                    }
                    return;
                }

                Debug.Assert(!row.inChangingEvent, "How can this row be in an infinite loop?");

                row.tempRecord = proposedRecord;
            }
            DataRowChangeEventArgs drcevent = null;

            try {
                row._action = action;
                drcevent = RaiseRowChanging(null, row, action, fireEvent);
            }
            catch {
                row.tempRecord = -1;
                throw;
            }
            finally {
                row._action = DataRowAction.Nothing;
            }

            row.tempRecord = -1;

            int currentRecord = row.newRecord;

            // if we're deleting, then the oldRecord value will change, so need to track that if it's distinct from the newRecord.
            int secondRecord = (proposedRecord != -1 ?
                                proposedRecord :
                                (row.RowState != DataRowState.Unchanged ?
                                 row.oldRecord :
                                 -1));

            if (action == DataRowAction.Add) { //if we come here from insert we do insert the row to collection
                if (position == -1)
                    Rows.ArrayAdd(row);
                else
                    Rows.ArrayInsert(row, position);
            }

            List<DataRow> cachedRows = null;
            if ((action == DataRowAction.Delete || action == DataRowAction.Change)
                && dependentColumns != null && dependentColumns.Count > 0) {
                // if there are expression columns, need to cache related rows for deletes and updates (key changes)
                // before indexes are modified.
                cachedRows = new List<DataRow>();
                for (int j = 0; j < ParentRelations.Count; j++) {
                    DataRelation relation = ParentRelations[j];
                    if (relation.ChildTable != row.Table) {
                        continue;
                    }
                    cachedRows.InsertRange(cachedRows.Count, row.GetParentRows(relation));
                }

                for (int j = 0; j < ChildRelations.Count; j++) {
                    DataRelation relation = ChildRelations[j];
                    if (relation.ParentTable != row.Table) {
                        continue;
                    }
                    cachedRows.InsertRange(cachedRows.Count, row.GetChildRows(relation));
                }
            }

            // Dev10 Bug 688779: DataRowView.PropertyChanged are not raised on RejectChanges
            // if the newRecord is changing, the propertychanged event should be allowed to triggered for ListChangedType.Changed or .Moved
            // unless the specific condition is known that no data has changed, like DataRow.SetModified()
            if (!suppressEnsurePropertyChanged && !row.HasPropertyChanged && (row.newRecord != proposedRecord)
                && (-1 != proposedRecord) // explictly not fixing Dev10 Bug 692044: DataRowView.PropertyChanged are not raised on DataTable.Delete when mixing current and original records in RowStateFilter
                && (-1 != row.newRecord)) // explictly not fixing parts of Dev10 Bug 697909: when mixing current and original records in RowStateFilter
            {
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:DataTable.cs

示例4: SetNewRecordWorker

 private void SetNewRecordWorker(DataRow row, int proposedRecord, DataRowAction action, bool isInMerge, bool suppressEnsurePropertyChanged, int position, bool fireEvent, out Exception deferredException)
 {
     deferredException = null;
     if (row.tempRecord != proposedRecord)
     {
         if (!this.inDataLoad)
         {
             row.CheckInTable();
             this.CheckNotModifying(row);
         }
         if (proposedRecord == row.newRecord)
         {
             if (isInMerge)
             {
                 this.RaiseRowChanged(null, row, action);
             }
             return;
         }
         row.tempRecord = proposedRecord;
     }
     DataRowChangeEventArgs args = null;
     try
     {
         row._action = action;
         args = this.RaiseRowChanging(null, row, action, fireEvent);
     }
     catch
     {
         row.tempRecord = -1;
         throw;
     }
     finally
     {
         row._action = DataRowAction.Nothing;
     }
     row.tempRecord = -1;
     int newRecord = row.newRecord;
     int record = (proposedRecord != -1) ? proposedRecord : ((row.RowState != DataRowState.Unchanged) ? row.oldRecord : -1);
     if (action == DataRowAction.Add)
     {
         if (position == -1)
         {
             this.Rows.ArrayAdd(row);
         }
         else
         {
             this.Rows.ArrayInsert(row, position);
         }
     }
     List<DataRow> cachedRows = null;
     if (((action == DataRowAction.Delete) || (action == DataRowAction.Change)) && ((this.dependentColumns != null) && (this.dependentColumns.Count > 0)))
     {
         cachedRows = new List<DataRow>();
         for (int i = 0; i < this.ParentRelations.Count; i++)
         {
             DataRelation relation2 = this.ParentRelations[i];
             if (relation2.ChildTable == row.Table)
             {
                 cachedRows.InsertRange(cachedRows.Count, row.GetParentRows(relation2));
             }
         }
         for (int j = 0; j < this.ChildRelations.Count; j++)
         {
             DataRelation relation = this.ChildRelations[j];
             if (relation.ParentTable == row.Table)
             {
                 cachedRows.InsertRange(cachedRows.Count, row.GetChildRows(relation));
             }
         }
     }
     if (((!suppressEnsurePropertyChanged && !row.HasPropertyChanged) && ((row.newRecord != proposedRecord) && (-1 != proposedRecord))) && (-1 != row.newRecord))
     {
         row.LastChangedColumn = null;
         row.LastChangedColumn = null;
     }
     if (this.LiveIndexes.Count != 0)
     {
         if (((-1 == newRecord) && (-1 != proposedRecord)) && ((-1 != row.oldRecord) && (proposedRecord != row.oldRecord)))
         {
             newRecord = row.oldRecord;
         }
         DataViewRowState recordState = row.GetRecordState(newRecord);
         DataViewRowState state3 = row.GetRecordState(record);
         row.newRecord = proposedRecord;
         if (proposedRecord != -1)
         {
             this.recordManager[proposedRecord] = row;
         }
         DataViewRowState state2 = row.GetRecordState(newRecord);
         DataViewRowState state = row.GetRecordState(record);
         this.RecordStateChanged(newRecord, recordState, state2, record, state3, state);
     }
     else
     {
         row.newRecord = proposedRecord;
         if (proposedRecord != -1)
         {
             this.recordManager[proposedRecord] = row;
         }
     }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:DataTable.cs


注:本文中的System.Data.DataRow.CheckInTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。