c# - DataServiceContext not usable after after Serialize/Deserialize round-trip -


i'm struggling tombstoning support in wp 7.1 app. have single long-lived instance of dataservicecontext, serialize , deserialize using dataservicestate helper. upon deserialization, can retrieve instance of user class context using uri lookup key. e.g.,

var context= ... deserialized dataservicecontext ... var useridentity = ... uri identifies user instance ... user user = null; context.trygetentity(useridentity.tostring(), out user); 

but if try load property on user instance (that i've just pulled context) follows:

context.beginloadproperty(user, "foo", mycallback, null); 

the context throws invalidoperationexception message "the context not tracking entity." appears deserialization not preserve referential integrity of context.

i've created simple app demo issue. download skydrive: http://sdrv.ms/mhctla

the app uses sample data service @ http://services.odata.org/odata/odata.svc. manually ran datasvcutil create proxies in odatademo.cs. note had add datacontract attribute on class demoservice in generated code, no other changes have been made.

once app running, tap on "data service context" button. following page load of products data service, randomly select 1 retrieve context, cache identity uri of product, , load category property of product.

next, tap "serialize" button. app serializes context using dataservicestate.

finally, tap "deserialize" button. app deserializes context, , attempts following against resurrected context:

  1. get product using dataservicecontext.trygetentity , cached uri.
  2. get uri same product using dataservicecontext.trygeturi.
  3. load category property of product.

step 1 succeeds, while steps 2 , 3 fail. fact trygeturi cannot find descriptor entity retrieved context indicates wrong deserialized context.

am doing dreadfully wrong? or bug?

i have @ , possible. sharing repro project it'll useful.

edit: looks bug. workaround throw away context instance , attach instance new context.


Comments