如果实体具有 dataservicecollection 属性,wp7 odata v2 dataservicestate 恢复方法将引发异常

发布于 2024-10-10 21:09:14 字数 592 浏览 8 评论 0原文

我有一个使用 ODATA v2 库和 DataServiceState 类的 WP7 应用程序,我可以调用 DataServiceState.Save 方法在逻辑删除期间存储 DataServiceCollection。我还可以调用 DataServiceState.Restore 方法并成功恢复已保存的 DataServiceCollection。

当已保存的 DataServiceCollection 类型包含一个或多个已加载/扩展的 Collection 属性时,就会出现问题。

如果我不扩展这些属性(使用 Entities.BeginLoadProperty 方法),它就可以正常工作。但是,如果我展开一个或多个属性,当我尝试恢复集合时,我会收到以下异常

无法将项目添加到集合中。当 DataServiceCollection 中的项目 由 DataServiceContext 跟踪,在将项目加载到集合中之前无法添加新项目。

不确定我缺少什么 - DataServiceState 类应该解决尝试反序列化 ODATA DataServiceCollections 的问题 - 这似乎工作一层深度,但一旦达到 2 层 - 就会抛出异常,

谢谢 迈克尔

I have a WP7 app using the ODATA v2 library with DataServiceState class and I am able to call the DataServiceState.Save method to store a DataServiceCollection during tombstoning. I can also call the DataServiceState.Restore method and successfully restore a DataServiceCollection that was saved.

The problem arises when the DataServiceCollection Type that has been saved contains one or more Collection properties that have been loaded/expanded.

If I don't expand those properties (using the Entities.BeginLoadProperty method) it works fine. But if I expand one or more of the properties, when I try to restore the collection I get the following exception

An item could not be added to the collection. When items in a DataServiceCollection
are tracked by the DataServiceContext, new items cannot be added before items have been loaded into the collection.

Not sure what I am missing - the DataServiceState class is supposed to address the issues with trying to deserialize ODATA DataServiceCollections - which seems to work one level deep but as soon as it goes to 2 levels - the exception is thrown

thanks
Michael

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溺孤伤于心 2024-10-17 21:09:15

根据这篇文章: http: //social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/0806c41a-2699-4390-8aaf-14b9c75a9dca WP7 的 ODATA 库不适用于当前的 $expand 选项他们计划在下一个版本中更好地支持逻辑删除。

According to this post: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/0806c41a-2699-4390-8aaf-14b9c75a9dca the ODATA library for WP7 doesn't work with the $expand option in the current release and they're planning on better support for tombstoning in the next release.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文