Synchronization Services for ADO.NET
Offline Application Demo Series
I put together a simple demo application as a showcase of the new synchronization framework for ADO.NET that I am working on. I got excited and released another demo that it is slightly more advanced than the first one but not too much. On popular demand, I released the third demo to show the technology in N-Tier setup. As I got a lot of encouraging feedback along with more requests for demonstrating more features, I planned to grow the simple demo to build a series of demos.
Here is a quick overview of the series:
Demo I : Automatic Generation of SyncAdapterBuilder
This demo shows the quickest way to build offline application for bidirectional synchronization. It focuses on the use of SyncAdapterBuilder to generate all necessary commands needed for two way sync. An important part of the demo is the need to prepare the backend database for synchronization. The demo shows few steps to setup change tracking for every table we wish to synchronize with the client. It also show how to track deletes by populating a separate tombstone table using delete triggers.
Demo II : Authoring SyncAdapter Objects using TSQL and SProcs
This demo continues where 'Demo I' left off. It shows that while coding SyncAdapter manually might be a lot of code, it easy to do with the added benefit if better performance. The demo also shows "session parameters" which is a new concept in Sync Services. Session parameters are built in variables that you can and will use as parameters to your commands. The sync runtime job is to set the value of these parameters for you. When writing SyncAdapter, you need to understand which parameters you need and how to use them in your queries or procs. To show you both, I put wrote the Insert, Update and Delete commands as stored procedures and the enumeration commands as TSQL.
Demo III : N-Tier Setup Using Web Services
Things get exciting when you throw web services into the mix. In this demo, I took the server side and put it away in the mid tier where you can access it through web service only. The process is rather mechanical, the tricky part though is to get around type sharing issues when referencing the web service in the client application.
Demo IV : Conflict Detection and Resolution
Back to two-tier setup, this demo shows a relatively annoying side effect of lazy synchronization which is conflicts. The annoyance of conflicts is rather clear, on one hand end user hates conflicts, on the other hand developers are unable to decide how to deal with them. The demo does not give a magic solution to this problem, if one exists! It shows, however, how to plug into framework to detect conflicts and surface them to the end user or custom logic. It also shows several possible options for resolving conflicts. Pay special attention to the sync_force_write session parameter as it is the key to conflict resolution on the backend database.
Demo V : Oracle Backend
With Sync Services, the choice of the backend store is wide open. You can use SQL Server database of course, but you are not left to suffer if you have Oracle or any other database brand. In this installment of this demo series, I am going to show you how to use Sync Services to synchronize a table stored in Oracle database. The demo also shows how to author SyncSchema object to control how the table schema looks like on the client.
Demo VI : Decoupled Change Tracking
Enabling change tracking on the server database requires some changes to the database. In demo II, I presented one way of doing this by adding extra columns to the base table inline with the data. Coupling the data and metadata in the same table is not desired in many situations. To over come such limitation, we need to decouple the metadata from the data in separate table. In this demo, I show you have to achieve that while leaving the base table schema intact.
Demo VII : Tombstone Cleanup
Synchronization needs metadata and metadata needs maintenance. One of the maintenance tasks that you need to think about is cleaning up the tombstones. Remember, tombstones represent deleted rows. Tombstones accumulate with time affecting the performance and consume disk space. In this demo, I show you how to go about cleaning up tombstones using simple aging criteria. In addition, I show you how to detect clients that have not synchronized in long time and reject their synchronization request forcing them to reinitialize their local store which in turn protects the system from stale content and inconsistent views of the data.
Demo VIII : Batching
Building enterprise ready offline applications with the ability to synchronize large number of changes demand the support for batching. Synchronization Services for ADO.NET has an open batching model that puts the control in your hands. This demo shows the simplest implementation for batching logic. It also shows how to make use of sync progress events to build user friendly UI.
Copyright © 2010 - Rafik Robeal
All Rights Reserved