locked
Conflict resolution with SqlSyncProvider RRS feed

  • Question

  • I'm working on a collaborative sync scenario using SqlSyncProvider, and I've been following the example given in the help topic "Synchronizing SQL Server and SQL Server Compact ". But I also want to implement conflict resolution, for which the only documentation I can find is "How to: Handle Data Conflicts and Errors for Collaborative Synchronization " - which uses DbSyncProvider instead of SqlSyncProvider.

    Is it possible to implement conflict resolution using SqlSyncProvider? If so, is there any documentation available on how to do it?
    • Moved by Max Wang_1983 Thursday, April 21, 2011 11:26 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, September 9, 2009 8:48 AM

Answers

  • Patterns for conflict detection and resolution are the same across SqlSyncProvider and DbSyncProvider.  In the RTW docs, we will have samples for both but converting the one using DbSyncProvider should be trivial.

    Regards,


    Sean Kelley
    Senior Program Manager
    Microsoft
    Sunday, September 13, 2009 10:31 PM
    Moderator
  • No.  SqlSyncProvider generates these commands behind the scenes by binding the SyncAdapters to the stored procs created during provisioning.  Go ahead and ignore that code in the how to.

    Regards,
    Sean Kelley
    Senior Program Manager
    Microsoft
    Tuesday, September 15, 2009 2:35 PM
    Moderator

All replies

  • Patterns for conflict detection and resolution are the same across SqlSyncProvider and DbSyncProvider.  In the RTW docs, we will have samples for both but converting the one using DbSyncProvider should be trivial.

    Regards,


    Sean Kelley
    Senior Program Manager
    Microsoft
    Sunday, September 13, 2009 10:31 PM
    Moderator
  • You can use ApplyChangeFailedEvent

    provider.ApplyChangeFailed +=

    new EventHandler<DbApplyChangeFailedEventArgs>(provider_ApplyChangeFailed);


     

    void provider_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)

    {

    //Log if required

     

    switch (e.Conflict.Type)

    {

     

    case DbConflictType.LocalUpdateRemoteUpdate:

     

    //if (Any Condition)

    e.Action =

    ApplyAction.RetryWithForceWrite;

     

    break;

     

    case DbConflictType.LocalDeleteRemoteUpdate:

     

    //if (Any Condition)

    e.Action =

    ApplyAction.RetryWithForceWrite;

     

    break;

     

    default://continue local changes

     

    break;

    }

    }

    Tuesday, September 15, 2009 1:07 AM
  • Thanks for your reply, Sean.

    In the help topic I mentioned above using the DbSyncProvider class, there's a lot of code in the SampleSyncProvider class for performing CRUD operations. Is any of this code relevant when I'm using the SqlSyncProvider?

    Regards,
    Denis
    Tuesday, September 15, 2009 9:20 AM
  • No.  SqlSyncProvider generates these commands behind the scenes by binding the SyncAdapters to the stored procs created during provisioning.  Go ahead and ignore that code in the how to.

    Regards,
    Sean Kelley
    Senior Program Manager
    Microsoft
    Tuesday, September 15, 2009 2:35 PM
    Moderator