locked
Only Sync a subset of the Cached Tables

    Question

  • I have over a dozen Cached Tables.  In some cases I want to Synchronize all the Cached Tables; and in other cases, I only want to Synchronize a small subset (1, 2, or 3) for performance reasons.  The code samples I have seen use the following, which synchronizes all Cached Tables.

     

    DataCacheSyncAgent syncAgent = new DataCacheSyncAgent();

    Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();

     

     

    How would I go about synchronizing just 1 table?

     

    Thanks for the help,

    Jack

    • Moved by Tina_Tian Friday, April 22, 2011 8:07 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Thursday, October 2, 2008 3:04 AM

Answers

  • This works:

     

    Change the following code:

    DataCacheSyncAgent syncAgent = new DataCacheSyncAgent();

    Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();

     

     

    To this code, allows me to just sync the Tooling table, and I get a performance gain by not having to sync all the Cached tables:

    DataCacheSyncAgent syncAgent = new DataCacheSyncAgent();

    //Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();

     

    SyncProvider lp = syncAgent.LocalProvider;

    SyncProvider rp = syncAgent.RemoteProvider;

    SyncTable st = syncAgent.Tooling;

    SyncAgent sa = new SyncAgent(lp, rp);

    sa.Configuration.SyncTables.Add("Tooling");

    sa.Configuration.SyncTables["Tooling"].SyncDirection = SyncDirection.Bidirectional;

    Microsoft.Synchronization.Data.SyncStatistics syncStats2 = sa.Synchronize();

     

    Thursday, October 2, 2008 5:26 AM

All replies

  •  

    Hi

     

    Just to clarify first: are you trying to  sync a Sql Server and a SqlCe db through a WCF?

     

     

     

    Thanks

    FTSIX

    Thursday, October 2, 2008 4:19 AM
  • Hi, FTSIX

     

    Thank you for responding.

     

    I am using VS 2008 & VS SP1 in a Windows Form application.  The first step I took in building the app was to Add a "Local Database Cache" Item.  Through the wizard that runs when adding this Item, I chose to Cache several tables in an existing SQL Database.  The wizard then produced a DataSet and a SqlCe DB containing a replica of the SQL Database tables that I chose to cache.   The Client & Server Project locations are listed as being my Windows Form app.  The Server DB is listed as the Sql Server DB and the Client DB is listed as being a SqlCe db.  So I guess this would not qualify as using WCF.

     

    Jack

    Thursday, October 2, 2008 4:47 AM
  • This works:

     

    Change the following code:

    DataCacheSyncAgent syncAgent = new DataCacheSyncAgent();

    Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();

     

     

    To this code, allows me to just sync the Tooling table, and I get a performance gain by not having to sync all the Cached tables:

    DataCacheSyncAgent syncAgent = new DataCacheSyncAgent();

    //Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();

     

    SyncProvider lp = syncAgent.LocalProvider;

    SyncProvider rp = syncAgent.RemoteProvider;

    SyncTable st = syncAgent.Tooling;

    SyncAgent sa = new SyncAgent(lp, rp);

    sa.Configuration.SyncTables.Add("Tooling");

    sa.Configuration.SyncTables["Tooling"].SyncDirection = SyncDirection.Bidirectional;

    Microsoft.Synchronization.Data.SyncStatistics syncStats2 = sa.Synchronize();

     

    Thursday, October 2, 2008 5:26 AM