Tuesday, June 22, 2010

RIA Services Updating Queries

I am working on a Silverlight 4 and RIA Services. I needed to take a query from the server and update it every minute or with a button press. I put the code in to clear a local collection and re-call the query. I ran all of my tests using VS2010 on my laptop and everything worked great. I put the Silverlight app up on the server and gave it to someone that was doing a demo. It failed to do any updating.

At first, I thought it was an IIS caching issue. I have seen IIS do this with other projects. We tried a few things and it did not work at all. So I did a little bit a research on the RIA call that I was using for the callback. I was using this call...

theContext.Load(theContext.GetInfoByPageQuery(page), OnAllInfoLoaded, null);

Looking at the Load help, I tried out a different version that adds a LoadBehavior to the parameters.

theContext.Load(theContext.GetInfoByPageQuery(page), LoadBehavior.RefreshCurrent, OnAllInfoLoaded, null);

When I put this on the server it updated everything perfectly. This is something that alot of the online samples do not have in them so I thought I would share it.

I will be posting more about my adventures in Silverlight 4 and RIA services soon.

No comments: