locked
How to restrict client data to relevant time window RRS feed

  • Question

  • Hi there,

    I'm creating a mobile application that requires the use of Sync Services for ADO.NET. It's pretty much a textbook implementation. Sql CE 3.5 on the client side to SQLServer 2008 server side.

    My question revolves around filtering:

    The system requirement is that clients only carry relevant data for a certain amount of time (say 4 weeks). 
    As clients collect data (tickets in this case), it is expected that the ticket only stay on the device for 4 weeks.  The basic process is as follows (nothing complicated):

    1. Client inputs ticket
    2. Client syncs. Ticket is sent to server

    My question is: can sync services be used to purge the ticket from the client after 4 weeks pass since its creation date? I don't think I can delete the ticket from the client db outside of the sync process because I assume that would in affect end up deleting the ticket on the server at next sync.

    Is there a pattern or construct one can use to address this problem? I feel like i'm missing something obvious here as I'm sure this is a fairly common scenario...

    Thanks,
    Paul
    • Moved by Hengzhe Li Friday, April 22, 2011 5:22 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, March 6, 2009 9:08 PM

Answers

  • Please try the below approach.
    1. Subscribe either clientProvider.ChangesApplied event or clientProvider.ApplyingChanges event.
    2. In both event handler, the event argument e has a property Transaction.
    3. In the event handler, try to create a SqlCeCommand object using this Transaction object mentioned on #2.  The command text should delete the rows you like to delete.
    4. Execute the this SqlCeCommand.

    Thanks.


    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, March 10, 2009 5:36 PM
    Answerer

All replies

  • Please try the below approach.
    1. Subscribe either clientProvider.ChangesApplied event or clientProvider.ApplyingChanges event.
    2. In both event handler, the event argument e has a property Transaction.
    3. In the event handler, try to create a SqlCeCommand object using this Transaction object mentioned on #2.  The command text should delete the rows you like to delete.
    4. Execute the this SqlCeCommand.

    Thanks.


    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, March 10, 2009 5:36 PM
    Answerer
  • Hi Leo,

    would the way you suggested not lead to what Paul worried about - leading to a delete on the server on the next sync?

    Or is there any "magic" that prevents sync framework from not syncing back one specific change on the local db to the server db?
    I would be in search of this, my only solution for now is to call AcceptChanges() after I made all my custom calls.

    Regards,
    Andreas

    Monday, March 16, 2009 10:35 AM