none
Maintaining relevant data RRS feed

  • Question

  • Hi,

    I'm looking at my applications that use Sync for Devices and have had an idea for an issue that has been outstanding for a while.

    I want to get rid of old data off the device but don't want to download all data and then work out what is to go.  I have a solution and will work towards it but perhaps someone who knows all the ins and outs can tell me if I am really wrong.

    For the purpose of the pseudo code below assume that I'm just looking at 1 table called Companies

    Sync starts

    If it doesn't exist create a table called CompaniesToRemove

    Empty the CompaniesToRemove table

    Add in all of the PKs of the rows in Companies

    Now do sync

    As sync proceeds any processed rows in the Companies table should be removed from the CompaniesToRemove table *1

    Finally after sync finishes

    Delete the rows with PKs that are left in the CompaniesToRemove table *2

    The issues that I see are at *1 and *2.

    *1, I am assuming that all rows are processed on the client even if there are no changes.

    *2, I am assuming that there is a way to delete rows without triggering the delete/update on the row. 

    Any thoughts?

    Regards,

    Jon

     

    Thursday, July 14, 2011 11:41 AM

Answers

  • if you're going for a full reinit, just set the SyncDirection to Snapshot. my mistake, if the last received anchor has a value, it will skip the table creation part.

    • Marked as answer by JonUK Thursday, July 14, 2011 6:22 PM
    Thursday, July 14, 2011 4:02 PM
    Moderator

All replies

  • Hi All,

    Overshot with that one and now obvious that I was missing some information.

    My current tactic is to simply be happy with an occasional (daily) removal of the table to clear the data out.  I've seen a few threads discussing this and the best approach seems to be the full reinit of a table.  

    How do you go about using SyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable for a non-initial sync?

    Regards,

    Jon

    Thursday, July 14, 2011 2:21 PM
  • the table creation option gets used regardless of whether its an initial sync or subsequent sync.

    a full reinit works best if you only have a small subset of data though.

    Thursday, July 14, 2011 2:45 PM
    Moderator
  • Yeah it is a small amount of data - annoyingly small in fact, it's almost not worth using sync at all but as soon as I develop something else the dataset will grow - you know the story.

    I'm doing this kind of thing below on every sync.  Surely if it is on every sync then it would be dropping the table each time - but it isn't.  Could something else be overriding it?

    Dim otherSyncGroup As New SyncGroup("otherSyncGroup")

     

            Dim SyncTable As New SyncTable("tableName")

            SyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable

            SyncTable.SyncGroup = otherSyncGroup 

            SyncTable.SyncDirection = SyncDirection.DownloadOnly

            syncAgent.Configuration.SyncTables.Add(SyncTable)

    Regards,

    Jon

     

    Thursday, July 14, 2011 3:25 PM
  • if you're going for a full reinit, just set the SyncDirection to Snapshot. my mistake, if the last received anchor has a value, it will skip the table creation part.

    • Marked as answer by JonUK Thursday, July 14, 2011 6:22 PM
    Thursday, July 14, 2011 4:02 PM
    Moderator
  • You are an absolute star!  That's sorted out my issue of redundant data once and for all!  

    Many thanks for your help on that!

    Regards,

    Jon

    Thursday, July 14, 2011 6:24 PM