Thursday, January 17, 2013 1:56 PM
I'm new in Sync Framework and write some code that sync to database. I use upload direction and always data is transferred from server to client. Now I have some problems:
1. Some times require that truncate my destination table and without it, synchronization doesn't update records on destinations.Why? and How fix it?
2. When a record updated in destination table by user, Sync doesn't update it even this record updated in source table. How can I force that all records in destination table updated?
3. How can I update records in destination table, But value of specified columns doesn't updated and store it' old value?
Friday, January 18, 2013 1:18 AMModerator
1. as much as possible, avoid TRUNCATE commands. Sync Framework change tracking is based on triggers. TRUNCATE will not fire triggers, no triggers, no changes logged.
in your scenario, if you truncate the table, your user/base table is no longer in synched with its corresponding tracking table.
you said an update on the source doesn't get applied on the destination, you truncated it already, so there is nothing to update. Sync framework will not reinsert a row you removed.
2. if you update the record in both source and destination, you get a conflict. subscribe to the ApplyChangesFailed event and handle the conflict there by specifying which record should win.
am not sure I understand your third question.
Saturday, January 19, 2013 5:24 AM
Thanks for your help.
About first problem, I think must explain more. I didn't truncate source table. I always want to transfer records from source table to destination. But sometimes Sync didn't update destination table. I don't know the reason. But after truncate destination table, Sync transfer all records and operation done successfully. Please help me for the reason of it, and solution for it.
For second question, I will try and thank you.
But third, I have a table that all records must be transferred from source to destination. There is a field in this table that in source table is NULL. It will be updated in destination by user. In synchronize operation, I want to transfer all records in source to destination table, But if this field has a value in destination,don't updated and don't set to NULL.
Thanks again,more and more.
Monday, January 21, 2013 1:49 AMModerator
for your first issue, check the ApplyChangeFailed event if there are issues applying the change.
for your third issue, Sync Fx can't do that for you. Change tracking is at the row level, if a row has changed even if it's one column change, it will apply the entire row.
If you want to override that, you can subscribe to the ChangesSelected or ApplyingChange event and intercept the changes to see if its null and ignore the change.