locked
Sync Services Dynamic Filter RRS feed

  • Question

  • I have an issue with Sync Services when I download using a dynamic filter. Our field reps need to only download devices belonging to houesholds assigned to them. I used a filter as follows:

     

    string deviceFilterClause = " householdId in ('99')";

    deviceBuilder.FilterClause = deviceFilterClause;

     

    SyncAdapter deviceSyncAdapter = deviceBuilder.ToSyncAdapter();

    ((SqlParameter)deviceSyncAdapter.SelectIncrementalInsertsCommand.Parameters["@sync_last_received_anchor"]).DbType = DbType.DateTime;

    ((SqlParameter)deviceSyncAdapter.SelectIncrementalInsertsCommand.Parameters["@sync_new_received_anchor"]).DbType = DbType.DateTime;

     

    _serverSyncProvider.SyncAdapters.Add(deviceSyncAdapter)

     

     

    The first time it only downloads the household with id 99. Next time round when I change the deviceFilter clause to "100,102", it does not synchronize any of this data. Please help!!!!

     

     

    Thanks,

    Arshad

    • Moved by Max Wang_1983 Friday, April 22, 2011 8:09 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, April 4, 2008 4:15 PM

Answers

  • Apologize!! I'll take that back. When you do a snapshot, it doesn't create any anchors. So if you upload it will not upload anything. In my case, since I used the SyncAdapterBuilder, I first download using SyncDirection.DownloadOnly, then removed the sync anchor in SelectInsertsCommand.CommandText, then upload with SyncDirection.UploadOnly and everything works fine with a dynamic filter. You do however have to let the SyncParameters remain in the collection. Works like a charm.

     

    Arshad

     

    Tuesday, April 8, 2008 5:35 PM

All replies

  • This is what I got when I ran a trace on the server:

     

    exec sp_executesql N'SELECT [deviceId], [householdId], [deviceTypeCode], [deviceNumber], [modifyDate], [modifyBy], [createDate] FROM [DeviceTest] WHERE (createDate > @sync_last_received_anchor AND
    createDate <= @sync_new_received_anchor) and householdId = ''dab53dbc-74d7-46e9-a72b-00194e7fdda4''',N'@sync_last_received_anchor datetime,@sync_new_received_anchor
    datetime',@sync_last_received_anchor=''2008-04-04 15:06:53:737'',@sync_new_received_anchor=''2008-04-04 15:06:56:797''

     

    Thanks,

    Arshad

     

    Friday, April 4, 2008 7:17 PM
  •  

    Worked around this. The strategy is to force the upload of all data from the field reps first regardless of anchors and then get a snapshot of data from the server based on a dynamic filter. This way the dynamic filter doesn't have to bother about the create date of the item being later than the anchor date.

     

    Arshad

     

    Tuesday, April 8, 2008 2:23 PM
  • Apologize!! I'll take that back. When you do a snapshot, it doesn't create any anchors. So if you upload it will not upload anything. In my case, since I used the SyncAdapterBuilder, I first download using SyncDirection.DownloadOnly, then removed the sync anchor in SelectInsertsCommand.CommandText, then upload with SyncDirection.UploadOnly and everything works fine with a dynamic filter. You do however have to let the SyncParameters remain in the collection. Works like a charm.

     

    Arshad

     

    Tuesday, April 8, 2008 5:35 PM