locked
SyncAdapter Filter - dynamically filtered RRS feed

  • Question

  • Hi together,

    I am facing the following problem.

    I am using filters to reduce the amount of data transferred over the network when syncing my PDA device with my server.
    On the server side, I am using SQL Server Change Tracking + the SyncAdapterBuilder to sync data.

    When a client connects, it first downloads so called "Studies" to the client. Therefore, it syncs the Study table and the Text table, which contains the Names and Descriptions for my studies. (it's somehow a localizable app).
    when doing so, the client just needs to sync the rows of the Text table, belonging to any of the Studies, it wants to sync. therefore, I am using a filter property, whichs sets the correct statement.

    so at the first sync, to get the studies, everything is ok.

    at a later step, I want to sync other tables + again the Text table with the entries belonging to the now synced rows from the other tables. but somehow, this does not work and I don't know why. all the other tables are synced perfectly well, but the Text table still has the old entries (specified by the first filter I set during the first sync)

    In the documentation it is written:

    Sync Services does not provide automatic partition management. This has the following consequences:

    • If you update a row and change the value of a column that was used in filtering, the row is not automatically deleted from those clients whose partition included that row. Consider an application that downloads customer data based on postal code to a salesperson. If a customer moves its offices into a new postal code area, data for that customer is not removed from the salesperson who originally had it. If that functionality is required, you could develop a system that enables Sync Services to download that update as a delete.



    It seems, that the server knows, that the client did the sync for the Text table already and does not want to give the client more data.


    How can I change this behaviour? I want to sync the same table several times but always with different filters on it.


    Is this probably a bug in the sync FX?


    Help please. Any replys welcome.


    Br,
    Harald

    • Moved by Hengzhe Li Friday, April 22, 2011 3:15 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Saturday, May 2, 2009 8:26 PM

Answers

  • Hi Harald,

    If I understand your scenario you are synching a table using a specific filter and later want to get more rows from the same table. I am also assuming that the new rows you want from this table have not changed since you last synched from this table. If this is your scenario then the default behavior is expected. You will not get the second set of rows. This is what we refer to as dynamic filtering. Meaning you have changed the filter for a table between two syncs.

    Sync maintains an anchor for each table that is being synched. It uses this anchor to figure out what rows need to be enumerated from this table each time it syncs. Also at the end of the sync it updates the anchor with a new value. This means that only those rows that have been changed since the last sync will be evaluated for enumeration. A user supplied filter will be applied to this set and then the rows that qualify both criterias will sync. Changing the filter will not cause unchanged rows to be sent to the client in next sync. The row has to change for it to even be evaluated for sync. In addition as mentioned in the doc if you change the filter and a row that used to qualify now falls out of the filter, it will not be deleted from the client.

    In short changing filters on tables between syncs is not supported. So what can you do. If all tables are in the same syncgroup you can write the select commands of your "target" table such that it always first filters the "other" table using the table level anchor looking for new rows and then joins to the "target" table to get the row data. Depending on your scenario this will give you the join dependency you are looking for.


    thanks
    Sudarshan

     


    Development Lead , Microsoft
    Monday, May 4, 2009 5:15 AM
    Moderator

All replies

  • Hey,

    is there nobody out there having the same problem or who had the same problem and probably solved it already?

    Any official statements from MS to this Q?

    Thx,
    Harald
    Sunday, May 3, 2009 3:35 PM
  • Hi Harald,

    If I understand your scenario you are synching a table using a specific filter and later want to get more rows from the same table. I am also assuming that the new rows you want from this table have not changed since you last synched from this table. If this is your scenario then the default behavior is expected. You will not get the second set of rows. This is what we refer to as dynamic filtering. Meaning you have changed the filter for a table between two syncs.

    Sync maintains an anchor for each table that is being synched. It uses this anchor to figure out what rows need to be enumerated from this table each time it syncs. Also at the end of the sync it updates the anchor with a new value. This means that only those rows that have been changed since the last sync will be evaluated for enumeration. A user supplied filter will be applied to this set and then the rows that qualify both criterias will sync. Changing the filter will not cause unchanged rows to be sent to the client in next sync. The row has to change for it to even be evaluated for sync. In addition as mentioned in the doc if you change the filter and a row that used to qualify now falls out of the filter, it will not be deleted from the client.

    In short changing filters on tables between syncs is not supported. So what can you do. If all tables are in the same syncgroup you can write the select commands of your "target" table such that it always first filters the "other" table using the table level anchor looking for new rows and then joins to the "target" table to get the row data. Depending on your scenario this will give you the join dependency you are looking for.


    thanks
    Sudarshan

     


    Development Lead , Microsoft
    Monday, May 4, 2009 5:15 AM
    Moderator
  • Hey Sudarshan,

    thanks a lot for you reply.

    too bad, that it's not a bug but a feature (or at least behavior as expected). In my special case, I'd need an other behavior.

    You wrote, that I should change the commands to get the row data I need.
    Do you have any idea if this is possible using the AdapterBuilder again? Can I influence the way the adapter builder joins the tables?

    would be great, if you could provide me with some more info concerning this.

    thanks a lot,
    harald

    ps: I'll mark your post as answer to this Q
    Monday, May 4, 2009 7:09 PM
  • Hi Harald,

    The AdapterBuilder does not create commands automatically for this scenario. You need to build it manually. Are you looking for sample commands that show joins between two tables ? I can see if I can find such a sample.

    thanks
    Sudarshan
    Development Lead , Microsoft
    Monday, May 4, 2009 8:42 PM
    Moderator
  • Hey Sudarshan,

    it would be great, if you could provide me with some sample commands or a sample code.

    Thanks in advance,
    Harald
    Tuesday, May 5, 2009 7:07 AM
  • Hey,

    anybody out there?

    Do you have any sample code for this problem?

    thanks
    Harald
    Tuesday, May 19, 2009 9:39 PM