locked
Is there a way to get the non-synchronized changes? RRS feed

  • Question

  • Is there an easy way to enumerate the changes that have been made on the client context which have not yet been uploaded to the server? The offlinecontext class has a method, getchangeset(), but it requires a Guid parameter and I am unfamiliar with how to use it.

    Thanks for the help

    Friday, December 3, 2010 6:05 PM

Answers

  • So every item in the context would have one of these 4 states:

    Detached (when the item has not been added to any collection within the context)

    Modified - when the item is part of some collection but has been modified

    Saved - when the item has been modied and Saved to the context by calling SaveChanges

    Unmodified - when the item is in sync with the service

    So in your case, you could go over all the collections in your context and look for items with state != Unmodified. These would the set of unsynced changes - both committed and uncommitted. For only committed changes, look for items with state as Saved.

    Sameer

    • Proposed as answer by Sameer[MSFT] Thursday, December 9, 2010 12:15 AM
    • Marked as answer by Ganeshan Saturday, December 11, 2010 2:11 AM
    Thursday, December 9, 2010 12:13 AM
  • The GetChangeSet() method is used by the cache controller to obtain the set of changes, this method can only be called during an active sync after BeginSession() is called.

    Like Sameer said you to get the list of changes you would have to call GetCollection<T>() method for all your collections of entities, and then select the ones whose EntityState != Unmodified


    Maria del Mar Alvarez Rohena Microsoft Sync Framework
    Thursday, December 9, 2010 12:30 AM

All replies

  • So every item in the context would have one of these 4 states:

    Detached (when the item has not been added to any collection within the context)

    Modified - when the item is part of some collection but has been modified

    Saved - when the item has been modied and Saved to the context by calling SaveChanges

    Unmodified - when the item is in sync with the service

    So in your case, you could go over all the collections in your context and look for items with state != Unmodified. These would the set of unsynced changes - both committed and uncommitted. For only committed changes, look for items with state as Saved.

    Sameer

    • Proposed as answer by Sameer[MSFT] Thursday, December 9, 2010 12:15 AM
    • Marked as answer by Ganeshan Saturday, December 11, 2010 2:11 AM
    Thursday, December 9, 2010 12:13 AM
  • The GetChangeSet() method is used by the cache controller to obtain the set of changes, this method can only be called during an active sync after BeginSession() is called.

    Like Sameer said you to get the list of changes you would have to call GetCollection<T>() method for all your collections of entities, and then select the ones whose EntityState != Unmodified


    Maria del Mar Alvarez Rohena Microsoft Sync Framework
    Thursday, December 9, 2010 12:30 AM