同步框架处理 ClientInsert ServerInsert 冲突
我有一个应用程序,它使用 LocalDataCache 将 SQL Server 2008 Express 数据库同步到客户端数据库(.sdf 文件)。这非常有效,我现在正在处理冲突。
我使用此 Microsoft 资源作为指南:如何:处理数据冲突和错误
我特别感兴趣的冲突是ConflictType.ClientInsertServerInsert。
我想在客户端和服务器上插入冲突的行,我想知道 SyncFramework 是否有内部方法可以执行此操作?
否则我的解决方案如下:
0 - 设置 e.Action = ApplyAction.Continue (无更改)。
1 - 将客户端冲突(id、表名)保存到数组中。
2 - 将服务器冲突(id、表名)保存到数组中。
3 - 对于客户端冲突数组中的每个项目,插入到服务器
4 - 对于服务器冲突数组中的每个项目,插入到客户端
我想知道 SyncFramework 是否可以为我执行此操作,因为它似乎可以为我执行其他所有操作?
我期待您的回复。谢谢
I have a application that uses LocalDataCache to synchronise a SQL Server 2008 Express database to a client database (.sdf file). This works great and I am now managing the conflicts.
I am using this Microsoft resource as a guide: How to: Handle Data Conflicts and Errors
The conflict I am particularly interested in is ConflictType.ClientInsertServerInsert.
I would like to Insert BOTH conflicting rows on the client AND server and I am wondering if there is an internal method to the SyncFramework to do this?
Otherwise my solution is as follows:
0 - Set e.Action = ApplyAction.Continue (no changes).
1 - Save Client conflict (id, tablename) into an array.
2 - Save Server conflict (id, tablename) into an array.
3 - For each item in the client conflict array, insert into server
4 - For each item in the server conflict array, insert into client
I am wondering if the SyncFramework can do this for me as it seems to do everything else for me?
I look forward to your replies. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我现在已经通过使用 PK 的 GUID 而不是自动递增 int 解决了这个问题。这保证了服务器或任何客户端插入的每一行都是唯一的。我知道存在一些缺点,例如额外的存储空间和搜索所需的时间,但这是我愿意接受的(并且我将过滤客户端获取的数据,这将有助于提高性能)。
I have fixed this problem now by using a GUID for a PK instead of a auto-incrementing int. This guarantees that each row inserted by the server or any client will be unique. I know there are some disadvantages such as additional storage space and time it takes to search but this is something I am willing to live with (and I will filter the data that the client gets which will help to improve performance).