如果实体具有 dataservicecollection 属性,wp7 odata v2 dataservicestate 恢复方法将引发异常
我有一个使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据这篇文章: 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.