限制同步字段
我正在构建一个在 Windows Mobile 设备上运行的应用程序。我正在使用 Microsoft 的同步框架将 Sql CE 数据库与主要的公司数据库同步。
问题是如何限制同步的字段?有问题的表有一堆字段,但我只需要在移动设备上显示其中的一些字段,并且复制只是一种方式(从服务器到移动设备),因此这不应该成为问题。我见过这个类似的问题,但是那里没有太多信息。谁能给我更多关于如何实现这一目标的建议?我想这是一个非常普遍的要求。
另外,有谁知道我是否可以使用 Sync Framework 版本 2.0,还是必须坚持使用 1.0。我感觉 2.0 不支持 Windows Mobile,但我不确定。
干杯
标记
I'm building an application that runs on a Windows Mobile device. I'm using Microsoft's Sync Framework to sync the Sql CE database with the main corporate db.
The question is how can I limit the fields that are syncronized? The table in question has stacks of fields but I only need to display a few of them on the mobile device and replication is only one way (from the server to the mobile) so that shouldn't be an issue. I've seen this similar question but there's not much info there. Can anyone give me more advice on how to achieve this? I imagine that it's a very common requirement.
Also, does anyone know if I can use the Sync Framework Version 2.0 or do I have to stick to 1.0. I had a feeling that 2.0 doesn't support Windows Mobile but I'm not sure.
Cheers
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以更改后台生成的 T-SQL,使其不包含表的所有列,但这里有一些问题。首先,这意味着您以后无法使用向导来修改同步选择 - 没什么大不了的,并且创建您自己的部分类来仅使用表的 T-SQL 覆盖特定方法可以稍微缓解这种情况。
其次,对未包含的(不确定这是否是一个单词?)列的更改也可以触发该行的下载,因为默认情况下更改跟踪是按行进行的。您可以通过设置 Track_Columns_Updated 标志来更改此设置
根据行数、数据大小和更新频率,我经常发现一个更简单的解决方案是在服务器的主表上提供触发器来更新单独表中的记录仅包含您需要的数据,然后进行同步。它使更改稍后下载的内容变得更加容易。如果你要下载莎士比亚的全部作品,这显然不是一个解决方案,但对于一个产品目录的几千条记录,我认为这是完全可行的。
You can change the T-SQL that's generated behind the scenes to not include all the columns of the table, but there are a couple of gotchas here. Firstly, it means that you can't use a wizard to modify the sync selection later - not a big deal, and creating your own partial class to override just the specific method with the T-SQL for your table mitigates that a bit.
Second, changes to the unincluded (not sure if that's a word?) columns can also trigger a download of that row as by default the change tracking is by row. You can change this by setting the Track_Columns_Updated flag
Depending on the number of rows and size of the data and frequency updated, I have often found an easier solution is to provide a trigger on the main table of the server to update records in a separate table containing just the data you need, then sync that. It makes it much easier to change what's downloaded later. This is obviously not a solution if you are downloading the entire works of Shakespeare, but for a few 1000 records of a product catalogue, I think it's perfectly feasible.