I setup sync framework 2.1 and I managed to sync between local and remote server ok. I use a template to filter by branch_id and I am able to bring proper records from branch (remote server) to local. Everything works fine, I can add or edit records on any of the servers and then sync (on local) and the records are updated on both just fine. The problem comes when I delete records on remote they are not deleted on local, curiously when I delete on local, records are actually deleted on server just fine.
If I remove the filter template everything works 100% ok, but I need to filter records by branch_id as it will take more time to download all records from other branches and that are not necessary to have.
Is it the filter not allowing de deletion of records on local?
why is this hapenning even if deleted records are from the same branch_id?
Is there a way that when records are deleted allow the framework to handle it as witouth filters?
For those who know how it works this is the basic scenario of the code:
1 - I create the template with the filter column by branch_id
2 - I create the local provisioning
3 - I create the remote provisioning and this is where I populate the template just created and apply the branch_id parameter, the scope name here can be "sectionNameScope_2075", "sectionNameScope_2076" and so on.
This is the error scenario:
1 - I can create or edit records on local or remote and everything works fine.
2 - I can delete records on local and everything works fine to.
3 - When I delete records on remote and when I sync the records are not being deleted on local, even when they have the same branch_id (local and remote)
Edit: One recomendation was to override the SelectingChanges event in the orchestrator but I do not know how to achieve so.
It turns out that when I was setting the parameter in the template instead of using [side] I was using [base], thus causing this strange behaviour. I do not know why I worked fine with base instead of side even when you look at the sp_select_changes stored procedure and find that base is the main table alias, but because of that I did not suspected that was the issue.
// changed this
remoteServerProvisionTemplate.Tables["users"].FilterClause = "[base].[branch_id] = @branch_id";
// to this
remoteServerProvisionTemplate.Tables["users"].FilterClause = "[side].[branch_id] = @branch_id";