"It worked for me:
dataContext.customer.Context.Refresh(RefreshMode.StoreWins, item);
Where item is the customer item be returned.
I ran tests with ObjectContext.Refresh in SQL Azure, and "RefreshMode.StoreWins" launches a database query for each object and causes a performance leak. Based on Microsoft documentation ():
ClientWins: Property changes made by objects in the context of an object are not replaced by values from the data source. The next time SaveChanges is called, these changes are sent to the data source.
StoreWins: Property changes made to objects in the context of the object are replaced with values from the data source.
ClientWins is not a good idea either because firing .SaveChanges will make "discarded" changes to the data source.
I don’t know what’s best, because getting rid of the context and creating a new one caused an exception from the message: “The original provider refused to open” when I try to run any request in the newly created context.
Respectfully,
Henrique clausing
Henrique Clausing Cunha May 04 '12 at 21:17 2012-05-04 21:17
source share