Freitag, 7. Mai 2010

Refresh cached EntitySet of Silverlight Client

If we loads a set of entities with WCF RIA Services they will be cached in an EntitySet on the client-side (Silverlight client), so after submitting changes or a after making a other query for the same EntitySet, only the entities we have removed on the client will be removed from the client-side’s EntitySet. If someone else have removed some of the entities from the database we work against, we still have those cached on the client-side. At the moment there aren’t any reload features added to the WCF RIA Services, so we need to handle it by our self.

We can’t just make a new call to the Load method of our DomainContext, it will only merge the existing EntitySet with changes or add new entities, but not removing anything. So for example if you query objects with a special condition and make a other query with a different condition it will bring back a merged list of entities.

So, what I am doing is:

   1: // Clear the client cache
   2: _DomainContext.Geldanlages.Clear();
   3: // make the query
   4: _DomainContext.Load(queryWertpapier);
   5: _DomainContext.Load(queryWertpapier).Completed += new EventHandler(LoadItemsWP_Completed);

Keine Kommentare:

Kommentar veröffentlichen