Using Silverlight 4, Oracle 11g, and Entity Framework 4.
I use a DataServiceQuery to fill a DataGrid. Then, some local (non-EF) code updates the DB. I would like to use the same query to refresh the DataGrid with the updated/new data. The problem is, when I do that, it returns the old, original results. I have verified that the changes have, in fact, been committed to the DB prior to this code running:
DataServiceContext<T> dsContext= new DataServiceContext<T>(uri);
dsContext.MergeOption = MergeOption.NoTracking;
dsContext.SaveChangesDefaultOptions = SaveChangesOptions.ReplaceOnUpdate;
DataServiceQuery<T> dsQuery = dsContext.CreateQuery<T>(typeof(T).Name);
// oldQuery is an IQueryable<T>
dsQuery = (DataServiceQuery<T>)oldQuery;
var dsQuery = (DataServiceQuery<T>)oldQuery;
dsQuery.BeginExecute(new AsyncCallback(c =>
{
IEnumerable<T> result = dsQuery.EndExecute(c);
listSelectedRecord = new List<T>();
listSelectedRecord = result.ToList();
}), dsQuery);
As far as I can tell, the new dsQuery is not even being sent to the Oracle server, even though a new DataServiceContext is being created. It is apparently discovering that it has a cached copy somewhere. If I type the query into a browser, it returns the updated results.
Any suggestions on how to force the DS to reperform the query?
The astonishing answers to this question seem to be found here:
Does Silverlight cache web service calls?
and
https://connect.microsoft.com/VisualStudio/feedback/details/340931/silverlight-webclient-does-not-download-updated-resources
There seems to be be some sort of vague consensus that SLx does indeed rely on the browser cache, not that you would know that from the
DataService,DataServiceContext, orDataServiceQuerydocs.So the easiest fix for this, in IE 8 at least, is to turn off browser caching.