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
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.