October 31, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

My First Microsoft Sync Framework Application

  • April 6, 2009
  • By Matt Goebel, Rachel Baker
  • Send Email »
  • More Articles »

We now have a simple application that allows us to take the salesperson data offline for viewing while disconnected and the functionality to get the latest data while connected. If you run the application now and view some records, make some changes to the server side data, and hit sync, you will see how the data changes get pulled down to the local data cache. This is pretty great, especially considering that only one line of code was written; however, most applications will want to send data changes back to the server. This is where bidirectional sync comes into play.

To enable bidirectional synchronization, right click on the AWLocalDataCache.sync file and select View Code. For each table that requires bidirectional sync (meaning users can update and receive updates for the data), we will need to add a single line of code in the table's OnInitialized method. Since we are interested in bidirectional sync for the SalesPerson table, we will add the following code to the method:

this.Sales_SalesPerson.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional;

Now when we run the application, the changes we make on the client will also be sent to the server. Please note that if are using the AdventureWorks database, you may need to disable existing update triggers to prevent issues from occurring during synchronization.

Conclusion

With the Microsoft Sync Framework and Visual Studio 2008, we can enable occasionally-connected data synchronization capabilities through some simple configuration dialogs and a couple of (really simple) lines of code. This allows us to rapidly create applications that can automatically manage the flow of data across distributed systems. For example, think of an application that is used by a mobile sales force in rural environments where the salespeople do not have reliable Internet connections. With MSF, we can enable our applications for offline support and reach customers even in dreaded Internet dead zones.

About the Authors

Matt Goebel is a manager with Crowe Horwath LLP in the Indianapolis, Indiana, office. He can be reached at 317.208.2555 or . Rachel Baker is a senior developer with Crowe Horwath LLP in the Oak Brook, Illinois, office. She can be reached at 630.990.4434 or .





Page 3 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel