Entities in Silverlight client aren't being updated when data is refreshed from the server RRS feed

  • Question

  • I am working on a Silverlight DataGrid that communicates with a data services server using the Data Services Silverlight client code. One of the properties of the entities is a SortOrder int.


    The user can change the sort order in the Silverlight client. At that point they have the option of submitting or canceling their changes.


    If the user cancels their changes, I refresh the client-side data from the server by issuing a new Data Services query. The data objects on the client side are not being updated with the new data from the server. For example, a particular object has been moved from SortOrder=5 to SortOrder=2. After the refresh the SortOrder should be reset to 5, the value on the server. However, the value is still 2.


    I used Fiddler to check the request (which is fine) and the response. The response shows the correct SortOrder (5 in this example). After the data comes back from the server I check the actual objects in the IEnumerable<T> being returned from query.EndExecute.  The particular object in question definitely still has a SortOrder value of 2 rather than 5.  In addition, neither the OnSortOrderChanging or OnSortOrderChanged partial methods are called when the query for refreshing the data is executed.


    Any thoughts?  Thanks,



    Wednesday, August 13, 2008 3:06 PM

All replies

  • I resolved this issue by creating a new DataServiceContext-derived object on the client side for the new query.  See this post for a follow-up question about when a new DataServiceContext object needs to be created: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3741538&SiteID=1 .

    Wednesday, August 13, 2008 4:46 PM
  • The correct answer to this question is that the DataServiceContext can be reused.  I needed to set DataServiceContext.MergeOption to "OverwriteChanges".  That affects the behavior of the DataServiceContext wrt the data that gets returned from the server.  See the link above for more information including responses from the Astoria team.



    Wednesday, August 13, 2008 5:00 PM