locked
How to Synchronise selected columns only using Microsoft Sync Framework ?? RRS feed

  • Question

  • i have 1 table on server side and same table at client side..

    i am using Microsoft Sync Framework to synchronise database..

    but if changes are made at server side and client side at same time then i am losing data of client side..\

    So i want to Synchronize selected columns only.

    Can you tell me how can i do it???/

    Thursday, April 21, 2011 1:03 PM

Answers

  • there is no column changetracking in Microsoft Sync Framework but there is a way to handle conflicts yourself.

    SCOPENAMESuncService.svc.cs

    [SyncConflictInterceptor("SCOPENAME")]
      public SyncConflictResolution SyncInterceptor(SyncConflictContext operationContext, out IOfflineEntity mergedVersion)
      {
       SyncConflictResolution resolution;
       resolution = SyncConflictResolution.ClientWins;
    mergedVersion = operationContext.ClientChange; return resolution;
    }
     in operationContext you can find the rows and columns that are in conflict. With the information from both you could make a "mergedVersion".
    or you can say who is right by returning a resolution.
     
    • Marked as answer by kishan1990 Friday, April 22, 2011 5:06 AM
    Thursday, April 21, 2011 2:44 PM
  • Are you using MSF v4 CT2 or an earlier version ?

    For v4 CT2, you can specify the conflict resolution policy in the web.config file when deploying the service, like

      <appSettings >
        <add key="ConflictResolutionPolicy" value="ServerWins"/>
    ...

    Also, you can intercept the conflicts on the server side and decide which version you want to win at run time. For this, you conflict interceptor. Here's more information http://msdn.microsoft.com/en-us/library/gg299068(v=SQL.110).aspx

    On the other hand, if you are using an older version of Synch Framework, and synchronizing data using SQLSyncProvider or one its derivatives, you can specify the conflict resolution policy in the ProcessChangeBatch call, here's the link:

    http://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.relationalsyncprovider.processchangebatch(v=sql.110).aspx

    here is another related thread : http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/11e4189d-6f3d-44e3-a6b0-a9964e733d40

    Hope these help.

    Sameer

     

    • Proposed as answer by Sameer[MSFT] Thursday, April 21, 2011 3:11 PM
    • Marked as answer by kishan1990 Friday, April 22, 2011 5:06 AM
    Thursday, April 21, 2011 3:11 PM

All replies

  • there is no column changetracking in Microsoft Sync Framework but there is a way to handle conflicts yourself.

    SCOPENAMESuncService.svc.cs

    [SyncConflictInterceptor("SCOPENAME")]
      public SyncConflictResolution SyncInterceptor(SyncConflictContext operationContext, out IOfflineEntity mergedVersion)
      {
       SyncConflictResolution resolution;
       resolution = SyncConflictResolution.ClientWins;
    mergedVersion = operationContext.ClientChange; return resolution;
    }
     in operationContext you can find the rows and columns that are in conflict. With the information from both you could make a "mergedVersion".
    or you can say who is right by returning a resolution.
     
    • Marked as answer by kishan1990 Friday, April 22, 2011 5:06 AM
    Thursday, April 21, 2011 2:44 PM
  • Are you using MSF v4 CT2 or an earlier version ?

    For v4 CT2, you can specify the conflict resolution policy in the web.config file when deploying the service, like

      <appSettings >
        <add key="ConflictResolutionPolicy" value="ServerWins"/>
    ...

    Also, you can intercept the conflicts on the server side and decide which version you want to win at run time. For this, you conflict interceptor. Here's more information http://msdn.microsoft.com/en-us/library/gg299068(v=SQL.110).aspx

    On the other hand, if you are using an older version of Synch Framework, and synchronizing data using SQLSyncProvider or one its derivatives, you can specify the conflict resolution policy in the ProcessChangeBatch call, here's the link:

    http://msdn.microsoft.com/en-us/library/microsoft.synchronization.data.relationalsyncprovider.processchangebatch(v=sql.110).aspx

    here is another related thread : http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/11e4189d-6f3d-44e3-a6b0-a9964e733d40

    Hope these help.

    Sameer

     

    • Proposed as answer by Sameer[MSFT] Thursday, April 21, 2011 3:11 PM
    • Marked as answer by kishan1990 Friday, April 22, 2011 5:06 AM
    Thursday, April 21, 2011 3:11 PM