silverlight - WCF Data Services UpdateObject not working -


i have silverlight client grid getting data wcf data service. works fine.

however if want update changed grid row, service data context updateobject not working:

    dataservicecontext.updateobject(mygrid.selecteditem);     foreach (object item in dataservicecontext.entities)     {         //     }     dataservicecontext.beginsavechanges(savechangesoptions.batch, onchangessaved, dataservicecontext); 

i have created loop inspect values entities items , value not updated @ all. beginsavechanges works fine, uses not updated values.

any ideas how fix that?

thanks

right flushed out savechanges show error message if endsavechanges() fails, code sample below. can't use console write out message in silverlight, idea.

for instance, when wrote following sample, found getting forbidden error, because entity set had entitysetrights.allread, not entitysetrights.all

 class program     {         private static adventureworksentities svc;          static void main(string[] args)         {             svc =                 new adventureworksentities(                     new uri("http://localhost:5068/awdataservice.svc",                          urikind.absolute));             var productquery = p in svc.products                     p.productid == 740                     select p;             var product = productquery.first();             showproduct(product);             product.color = product.color == "silver" ? "gray" : "silver";             svc.updateobject(product);             svc.beginsavechanges(savechangesoptions.batch, onsave, svc);             showproduct(product);             console.readkey();         }          private static void showproduct(product product)         {             console.writeline("id: {0} name: {1} color: {2}",                  product.productid, product.name, product.color);         }          private static void onsave(iasyncresult ar)         {             svc = ar.asyncstate adventureworksentities;             try             {                 writeresponse(svc.endsavechanges(ar));             }             catch (exception ex)             {                 console.writeline(ex.message);             }         }          private static void writeresponse(dataserviceresponse response)         {             if(response.isbatchresponse)             {                 console.writeline("batch response code: {0}", response.batchstatuscode);             }             foreach (changeoperationresponse change in response)             {                 console.writeline("change code: {0}", change.statuscode);                 if(change.error != null)                 {                     console.writeline("\terror: {0}", change.error.message);                 }             }         }     } 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -