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


C# DataContext.GetChangeSet方法代码示例

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


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

示例1: RefreshPendingChanges

 /// <summary>
 ///     Refreshes all pending Delete/Update entity objects of current DataContext according to the specified mode.
 ///     Nothing will do on Pending Insert entity objects.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="refreshMode">A value that specifies how optimistic concurrency conflicts are handled.</param>
 public void RefreshPendingChanges(DataContext context, RefreshMode refreshMode)
 {
     ChangeSet changeSet = context.GetChangeSet();
     if (changeSet != null)
     {
         context.Refresh(refreshMode, changeSet.Deletes);
         context.Refresh(refreshMode, changeSet.Updates);
     }
 }
开发者ID:NamedJohnny,项目名称:Real-Estate-Tour-Notebook-Windows-Phone-,代码行数:15,代码来源:DataServiceTour.cs

示例2: Flush

		private static void Flush(DataContext context)
		{
			var changeSet = context.GetChangeSet();
			changeSet.Inserts.OfType<ISavingChangesEventHandler>().ToList().ForEach(x => x.OnInsert());
			changeSet.Updates.OfType<ISavingChangesEventHandler>().ToList().ForEach(x => x.OnUpdate());
			changeSet.Deletes.OfType<ISavingChangesEventHandler>().ToList().ForEach(x => x.OnDelete());

			context.SubmitChanges();
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:9,代码来源:ProfileStorageSqlPersister.cs

示例3: CheckForInvalidVersions

        private static void CheckForInvalidVersions(DataContext _dataContext)
        {
            var changes = _dataContext.GetChangeSet();
            foreach (object item in changes.Updates)
            {
                ITable table = _dataContext.GetTable(item.GetType());
                object originalItem = table.GetOriginalEntityState(item);

                System.Data.Linq.Binary originalVerCol = (System.Data.Linq.Binary)originalItem.GetPropertyValue("VerCol");
                System.Data.Linq.Binary currentVerCol = (System.Data.Linq.Binary)item.GetPropertyValue("VerCol");
                if (!System.Data.Linq.Binary.Equals(currentVerCol, originalVerCol))
                {
                    throw new ChangeConflictException(string.Format("{0} object instance with ID ({1}) being modified with rowversion({2}) has different rowversion({3}) in database.", item.GetType().Name, item.GetPropertyValue("ID"), currentVerCol, originalVerCol));
                }
            }
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:16,代码来源:DataContextHelper.cs

示例4: DiscardPendingChanges

 public void DiscardPendingChanges(DataContext context)
 {
     RefreshPendingChanges(context, RefreshMode.OverwriteCurrentValues);
     ChangeSet changeSet = context.GetChangeSet();
     if (changeSet != null)
     {
         //Undo inserts
         foreach (object objToInsert in changeSet.Inserts)
         {
             context.GetTable(objToInsert.GetType()).DeleteOnSubmit(objToInsert);
             if (objToInsert is NearBy)
             {
                 (objToInsert as NearBy).Tour.NearBy.Remove((objToInsert as NearBy));
             }
             else if (objToInsert is Repair)
             {
                 (objToInsert as Repair).Tour.Repair.Remove((objToInsert as Repair));
             }
             else if (objToInsert is PictureTour)
             {
                 (objToInsert as PictureTour).Tour.Pictures.Remove((objToInsert as PictureTour));
             }
         }
         //Undo deletes
         foreach (object objToDelete in changeSet.Deletes)
         {
             context.GetTable(objToDelete.GetType()).InsertOnSubmit(objToDelete);
             if (objToDelete is NearBy)
             {
                 (objToDelete as NearBy).Tour.NearBy.Add((objToDelete as NearBy));
             }
             else if (objToDelete is Repair)
             {
                 (objToDelete as Repair).Tour.Repair.Add((objToDelete as Repair));
             }
             else if (objToDelete is PictureTour)
             {
                 (objToDelete as PictureTour).Tour.Pictures.Add((objToDelete as PictureTour));
             }
         }
     }
 }
开发者ID:NamedJohnny,项目名称:Real-Estate-Tour-Notebook-Windows-Phone-,代码行数:42,代码来源:DataServiceTour.cs

示例5: HasDbChanged

 /// <summary>
 /// Tells whether Database has changed indicating to trigger refresh all in memory objects
 /// </summary>
 /// <returns>true if database changed</returns>
 public static bool HasDbChanged(DataContext db)
 {
     ChangeSet changes = db.GetChangeSet();
     return (changes.Updates.Count > 0 || changes.Inserts.Count > 0 || changes.Deletes.Count > 0);
 }
开发者ID:Nithanaroy,项目名称:medicines-catalogue,代码行数:9,代码来源:ApplicationHelper.cs

示例6: ProcessUpdateItems

        //private static void ProcessInsertItems(DataContext _dataContext, DataContext _historyDataContext, int _userID)
        //{
        //    if (EntitiesToInsert.Count == 0)
        //        return;

        //    foreach (var item in EntitiesToInsert)
        //    {
        //        CopyTableColumns(item, CommitActionType.Insert, _historyDataContext, _userID);
        //    }
        //}

        private static void ProcessUpdateItems(DataContext _dataContext, DataContext _historyDataContext, int _userID)
        {
            ChangeSet CurrentChangeSet = _dataContext.GetChangeSet();

            foreach (object item in CurrentChangeSet.Updates)
            {
                ITable table = _dataContext.GetTable(item.GetType());
                object originalItem = table.GetOriginalEntityState(item);

                CommitActionType actionType = CommitActionType.Update;

                CopyTableColumns(originalItem, actionType, _historyDataContext, _userID);
            }
        }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:25,代码来源:DataContextHelper.cs

示例7: ProcessDeleteItems

 private static void ProcessDeleteItems(DataContext _dataContext, DataContext _historyDataContext, int _userID)
 {
     ChangeSet CurrentChangeSet = _dataContext.GetChangeSet();
     foreach (var item in CurrentChangeSet.Deletes)
     {
         CopyTableColumns(item, CommitActionType.Delete, _historyDataContext, _userID);
     }
 }
开发者ID:NGITechnology,项目名称:BeymenCheckout,代码行数:8,代码来源:DataContextHelper.cs


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