I'm trying to use WCF Data Services and I'm a little confused about where I'm wrong in tr开发者_JAVA技巧ying to update a record, based on a key field value.
My simplified approach, which doesn't work: MydbEntities context = new MydbEntities(new Uri("http://localhost:53051/Services/MydbService.svc"));
 MyEntity avt = context.MyTable.Where(p => p.EntID == "val1").FirstOrDefault();
 avt.FieldToEdit = 1;
 context.UpdateObject(avt);
 context.BeginSaveChanges(OnChangesSaved, context);
 ...
 private void OnChangesSaved(IAsyncResult result)
 {            
     MessageBox.Show("seems ok");//I'm getting this message, but, in fact, data in db remains unchanged
 }
Please, tell me, where am I wrong?
I've found the cause of the problem. It was trivial (I feel like an idiot), there was no writing access rights set in the service initializer. There was the following:
public static void InitializeService(DataServiceConfiguration config)
{
    config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
      ...
}
after I changed it to:
config.SetEntitySetAccessRule("*", EntitySetRights.All);
all started to work as expected. And, of course, such a broad access rule I set only for testing purposes. Later it should be restricted.
In your OnChangesSaved handler, you need to call context.EndSaveChanges(result).
This link has some sample code that illustrates the whole process.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论