同步框架:我可以仅同步表的子集吗?
使用同步框架同步数据的常规代码片段是这样的:
LocalDBSyncAgent syncAgent = new LocalDBSyncAgent();
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
有谁知道同步我的表子集的方法吗? 不要注意每个表内的数据,而是决定哪些表将参与同步。
谢谢 爱丽儿
The regular code snippet of syncing data with sync framework is this:
LocalDBSyncAgent syncAgent = new LocalDBSyncAgent();
Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize();
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.
Thanks
Ariel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,你绝对可以。
为每个要同步的表创建一个 SyncTable,并将其添加到 SyncAgent 中的 Configuration.SyncTables 中。
我发现这篇文章Bill Ryan 的非常有启发性。 他介绍了如何过滤每个表中的数据,但其中有一些东西可以满足您的需求。
比尔·瑞安的样本:
Yes, you absolutely can.
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.
Sample from Bill Ryan:
Sync Framework 2.0 中有一些新的与数据库相关的同步提供程序 - 与以前可用的同步提供程序相比,它们具有许多优点(请参阅比较提供程序类型 此处)。 通过这些,您可以通过构建仅包含您希望同步的那些表的 DbSyncTableDescription 的 DbSyncScopeDescription 来指定应同步表的子集。
您在上面说过您对过滤数据不感兴趣,但这里可能值得一提的是,DbSyncScopeDescription 还包含过滤信息。
There are some new database related sync providers in Sync Framework 2.0 - they have a number of benefits over the ones that were previously available (see Comparing Provider Types here). With these, you can specify that a subset of tables should be synchronized by building a DbSyncScopeDescription that contains DbSyncTableDescriptions for only those tables that you wish to synchronize.
You stated above that you are not interested in filtering the data but it is probably worth mentioning here that a DbSyncScopeDescription also contains filtering information.