Data synchronization framework Ms sync framework [terms, examples, references, tips]
Http://www.cnblogs.com/2018/archive/2011/02/22/1961654.html
Data synchronization framework Ms sync framework-Use Cases and brief analysis in different scenarios
Http://www.cnblogs.com/2018/archive/2011/02/23/1961657.html
The above two articlesArticleThe framework is described. The local database cache provided by IDE can quickly implement a common synchronization application. The details are as follows:
The MS sync framework is provided by vs for offline client use. The client is SQL compact, and the server can be SQL Server 2005/2008.
For more information, see:
Http://cid-56b433ad3d1871e3.office.live.com/self.aspx/.Public/SyncTest.rar
The dbcache directory is a specific example. The creation steps are as follows:
Template
After adding the file *. Sync, double-click the file to edit and modify it.
Synchronization settings
Double-click northwind. server. Sync or northwind. server. sync to modify
In SQL Server 2008, you can use SQL Server change tracking.
Sqlscripts sqlundoscripts: support and cancellation of database provison
Northwinddataset. XSD: cache access interface of the Client
Synchronization Code
Using (dataserviceproxy. northwindsynccontractclient datasvc = new dataserviceproxy. northwindsynccontractclient ())
{// Nwcache. SDF synchronize the data during default table Creation
Northwinddatasettableadapters. mermerstableadapter customerstableadapter
= New northwinddatasettableadapters. customerstableadapter ();
Northwinddataset = new northwinddataset ();
Customerstableadapter. Fill (northwinddataset. MERs mers );
New northwinddatasettableadapters. productstableadapter (). Fill (northwinddataset. products );
/// Modify (add, delete, modify) the SQL server's MERs table
Northwindsyncagent syncagent = new northwindsyncagent (datasvc );
Microsoft. synchronization. Data. syncstatistics syncstats = syncagent. Synchronize ();
Debug. writeline (syncstats. totalchangesdownloaded );
/// At this time, the client data has been synchronized
Customerstableadapter. Fill (northwinddataset. MERs mers );
New northwinddatasettableadapters. customerstableadapter (). Fill (northwinddataset. MERs mers );
New northwinddatasettableadapters. productstableadapter (). Fill (northwinddataset. products );
}
Summary
As shown above, you can quickly create a common sync using IDE.ProgramThe default program can only be downloaded. If you need two-way synchronization, refer to the SDK:
Walkthrough: extending the local database cache to support bidirectional Synchronization