wp7 odata v2 dataservicestate save and restore methods tombstoning example needed
Posted
by
MIantosca
on Stack Overflow
See other posts from Stack Overflow
or by MIantosca
Published on 2011-01-07T04:49:48Z
Indexed on
2011/01/07
4:53 UTC
Read the original article
Hit count: 228
windows-phone-7
|OData
I am looking for an example of how to use the new DataServiceState Save and Restore methods in a WP7 application in order to tombstone a datacontext - I cannot find any examples and the approach I used resulted in an exception
this saves the data context correctly
PhoneApplicationService.Current.State["DataContext"] = DataServiceState.Save(this.Model.Entities);
this attempts to restore it after the app is re-activated
var dc = (PhoneApplicationService.Current.State["DataContext"] as DataServiceState).Restore();
but throws an 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.
This is the same exception I get if I try to reload a datacontext that I stored "directly" (without using the DataServiceState.Save method) in the PhoneApplicationService.Current.State. I cannot find any offical documentation on the new ODATA v2 DataServiceState class or examples.
thanks Michael
© Stack Overflow or respective owner