locked
SaveChanges not returning fresh copy of entity RRS feed

  • Question

  • I have a call to RefreshChanges on the ADO.Net data context which works fine, on the server side I update a few things in the ChangeInterceptor (unique id, updated date etc) but I don't get the changes back to the client.

    I've looked at the http traffic and no fresh copy of the entity is being passed back.  The context has MergeOption set to OverwriteChanges but I figure that is not yet relevant because the entity refresh is not in the reply.

    ctx.MergeOption = MergeOption.OverwriteChanges;
    ctx.SaveChanges();

    Am I missing something which forces the updated entity to be passed back?

    Thanks in advance for any info.
    Sunday, December 14, 2008 8:09 PM

All replies

  • If you performing a update operation in the client, and you are updating a object in your change interceptor in the server, those changes won't be visible in the client, until you re-query the entity, since update operations do not return the entity in the response payload, and hence the client has no way of knowing if you made additional changes in the server.

    So after save changes, you should refresh the object by querying it again.

    Hope this helps.
    Thanks
    Pratik
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, December 15, 2008 1:29 AM
    Moderator
  • OK, thanks.  Is there an easy way to refresh a single entity on the context?
    Monday, December 15, 2008 3:00 AM
  • Good feedback. We will think about it in the future release about providing a Refresh method. For the time being, you can do the following:

    Uri uri;  
    context.TryGetUri(resource, out uri);  
    context.Execute<ResourceType>(uri); 

    Hope this helps.
    Thanks
    Pratik

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, December 15, 2008 5:24 PM
    Moderator