简体   繁体   中英

WCF Data services - Client is caching results

I have a WCF data service, my client is a WPF app.

I have a service operation in my WCF data services. something like that

[WebGet]
public IQueryable<VSuppliersExtra> GetAllVSuppliers()
{
    List<VSuppliersExtra> lstVsup = new List<VSuppliersExtra>();
    // add some VSuppliersExtra entities to the list
    ........
    return lstVsup.AsQueryable<VSuppliersExtra>();            
}

In my client I have

oCollection = new ObservableCollection<VSuppliersExtra>(jp.CreateQuery<VSuppliersExtra>("GetAllVSuppliers"));
//Open a new window Change collection and update the changes in the DB
.......
//run the same query again
.......
oCollection = new ObservableCollection<VSuppliersExtra>(jp.CreateQuery<VSuppliersExtra>("GetAllVSuppliers"));

Now, everything work just fine, BUT the 2nd call for the service operation will always get me the same results without the changes, until I restart my app.
I check the DB, all my changes are saved to the SQL server, I've checked the function in the service, and it does return the updated data... YET I get the same result set!!!! Is there some caching in the client side????

Well, I found some article http://msdn.microsoft.com/en-us/library/gg602811.aspx
I added a context.MergeOptions = MergeOption.OverwriteChanges;

That did the Trick.

Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM