best way sync specific records and their children RRS feed

  • Question

  • I am new to sync framework, and I'm trying to figure out how to use the row/table filtering capabilities.

    I have a host db with many records, tables, foreign key constraints.

    I have many clients. Each has the option to request specific records. I want the client to download only those records and their children, grand children, etc., do work against those children, and selectively upload their changes.

    Basically, I want a source safe. How do I leverage Sync Fx 2.1 for this?

    Monday, November 8, 2010 10:55 PM

All replies

  • Sync Fx doesnt allow you out-of-the-box to selectively specify which rows you want to synchronize.

    a workaround you can do is to create a filtered scope for each client where the filter is based on the rows they want to synchronize. take note though that you cannot modify a scope. so if the client changes what they want to synch, you'll have to deprovision and reprovision. you can also try storing the row PKs for the rows the client wants to sync in a separate table and specify a WHERE IN clause ( e.g. WHERE rowPK IN (select rowPK from rowsTobeSynchedTable where Userid=@Userid))

    Tuesday, November 9, 2010 4:08 PM
  • Well, I'm not sure what to do now.

    I am currently using Entity Framework for a SQL CE db on the client, and I have a WCF service to request/upload info to and from the server. Is passing a dataset back to the server the best way for me to upload my changes?

    If so, do I use some of the features in the DataSet class to reconcile the differences between my client version and my server version?

    Also, how should I manage synchronicity between multiple clients? More than one client may be working on a record set at any given time. Do I have to right up something to compare timestamps record by record, or is Sync Framework the right choice for me after all?

    I have some "downbound only" data. If that changes server-side, all clients should pick up that change. That seems easy enough for Sync Framework. But for my data that can change on either end, I'm not sure what to do.

    Any thoughts?

    Tuesday, November 9, 2010 7:55 PM
  • as i have mentioned, you still can use Sync Fx.

    if you have multiple clients updating the same row, then be prepared to handle the conflict. Sync Fx will detect the conflict and give you the opportunity to resolve it. You dont have the manually compare timestamps as Sync Fx can do this for you.

    Sync Fx can also be configured to work with WCF.

    Tuesday, November 9, 2010 11:28 PM
  • Ok, so I found a few samples and got a little test project up and running. It uses the local database cache designer and a wcf service library. Now for the tricky stuff:

    I don't want to synchronize the entire db. It would be much to large for that. I want a client side user to search for records, select those records, and pull those records down. I am guessing I could do this through filtering (since it's a feature I've only just heard of) . When the user is done, they should upload their changes. Since the user can have multiple records "checked out", they may still be working on some records while wanting to upload other records. This means that they need to choose which records they want to pull down, and of those, which records they want to post back. Is Sync Framework primed to solve this problem through filtering or is there another way?

    In addition, multiple users may be working on the same record set. I will need to merge those changes or have some sort of conflict resolution. If I go with a "last in wins", I'll just dump the record set to xml and push in the new one, stamping over everything. However, I don't want to maticulously compare record sets to delete rows from my server, but I suppose I will have to if Sync Framework is not right for me. Each record has many child tables each with possiblity of many rows. Comparing the server records with the client records would be a very tedious process.

    Also, in setting up my WCF Service with a local database cache, I was not able to expose the designer constructed sync provider through my own service. I had to use the sync service generated by the designer. Did I miss something? The examples I saw were able to reference the designer generated sync provider in other services. Also, I'm using Sync Framework 2.1. Maybe that was a breaking change.

    Wednesday, November 10, 2010 4:35 PM
  • When you say "if the client changes what they want to sync", are you referring to tables or rows or both?

    Would I have to deprovision and reprovision both the server and client databases? If so, what side effect would that have on other clients?

    Wednesday, November 10, 2010 4:45 PM
  • i mean the rows that the client tagged for synching.

    you only have to deprovision, provision the scope. the way it would work your scenario is that each client will have their own scope.


    i suggest you follow the walkthroughs/tutorials in the documentation so you get a feel how the scopes and filters work.

    Thursday, November 11, 2010 2:56 AM
  • Ok, so do I just need to come up with a unique scope naming scheme to prevent multiple client from using the same scope? Also, there will be a large number of tables of which each client will have exact, complete copies. Does that mean each client will have two scopes, a personal scope that contains the tables and rows they are working on, and a second "global" scope that every client will use?

    Also, the client has a few options to sync their data: Upload and Remove Local Copy, Upload but Keep Local Copy, Refresh Local Copy, Remove Local Copy

    For the situations when the client chooses to drop the local copy, deprovisioning those records makes a lot of sense.

    For the situations when the client is going to keep or refresh the local copy, I'm not sure about the appropriate way to handle the provisioning. For one, when I deprovision the client, will I be able to perserve some of the provisioning. I know I can deprovision a scope on my Sql provider, but I didn't see on for my SqlCe provider.

    Also, I looked into using Sync Framework through a WCF service. The only working sample I found was using a "Local Database Cache" template. It seemed largely different from the Sync 101 samples. There wasn't a way to specify a scope. It didn't have the same tracking tables. It didn't use a sync orchestrator. I'm sure all of that is handled somewhere else, but I couldn't find documentation to help me understand the tools are available, how they should be used, and which tools are right for me.

    It's hard to imagine my scenario being so different from an "out of the box" sample. I think Sync Framework could make quick work of this problem so that I don't have to write a bunch of tedious code to insert/update row upon row.

    Thursday, November 11, 2010 5:33 PM