同步框架:我可以只同步我的表的一个子集? [英] Sync Framework : Can I Sync only a subset of my tables?

查看:166
本文介绍了同步框架:我可以只同步我的表的一个子集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与同步框架同步数据的常规代码片段是这样的:

The regular code snippet of syncing data with sync framework is this:

LocalDBSyncAgent syncAgent = new LocalDBSyncAgent();
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();



做anynody知道的方式来同步我的表的子集。
注意不是每个表里面的数据,但在决定哪些表将在同步参与。

Do anynody knows a way to sync a subset of my tables. Note not the data inside each table but the decide which tables would be involved in the synchronization.

由于
阿里尔

推荐答案

是的,你绝对能。

对于要同步,并将其添加到在SyncAgent的Configuration.SyncTables每个表创建一个SyncTable。

Create a SyncTable for each table you want to sync, and add it to the Configuration.SyncTables in the SyncAgent.

我发现从比尔·瑞恩这篇文章非常有启发性。他走进如何在每个表中筛选数据,但有东西在里面,做你在找什么。

I found this article from Bill Ryan very instructive. He goes into how to filter data within each table, but there is stuff in there that does what you are looking for.

从比尔瑞安示例:

public class SampleSyncAgent : Microsoft.Synchronization.SyncAgent
 {

     public SampleSyncAgent()
     {

         SqlCeClientSyncProvider clientSyncProvider = new SqlCeClientSyncProvider(Properties.Settings.Default.ClientConnString, true);
         this.LocalProvider = clientSyncProvider;
              clientSyncProvider.ChangesApplied += new EventHandler<ChangesAppliedEventArgs>(clientSyncProvider_ChangesApplied);    

         this.RemoteProvider = new SampleServerSyncProvider();    

         SyncTable customerSyncTable = new SyncTable("Customer");
         customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
         customerSyncTable.SyncDirection = SyncDirection.DownloadOnly;**

         this.Configuration.SyncTables.Add(customerSyncTable);
         this.Configuration.SyncParameters.Add(new SyncParameter("@CustomerName", "Sharp Bikes"));
     }

}

这篇关于同步框架:我可以只同步我的表的一个子集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆