Print Page | Close Window

Refreshing Entity

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2435
Printed Date: 24-Jan-2026 at 7:52am


Topic: Refreshing Entity
Posted By: jipock
Subject: Refreshing Entity
Date Posted: 13-Jan-2011 at 8:07am

Good Morning,

I have what I think is a simple question.
 
I have a collection of entities that are already created. However, I need to do some sort of a refresh on this collection from the database. I can (and do) use the RefreshEntitiesAsync() function. However, when I refresh the entities, I need to add an 'Include' to include two more navigation entity properties that were not in the original entities. Ordinarily, if I were doing a query, I'd simply use the Include("XXX") path, but I don't see where refresh lets me do that.
 
Can anyone offer a suggestion?



Replies:
Posted By: gkneo
Date Posted: 13-Jan-2011 at 9:48am
hi.

You can try this (without using RefetchEntitiesAsync).  the variable myCollection is IEnumerable
var query= myCollection.Cast<MyEntityType>().ToQuery().Include("PropertyName1").Include("PropertyName2");

query.ExecuteQueryAsync( args=>
{
if (args.HasError) //show error

})


//or  you can use
myEntityManager.ExecuteQueryAsync(query, args=>
{
if (args.HasError) //show error
}
);


As you will notice, the query contains a  "where" clause which includes all the pks of the entities in your list. As the entities are loaded into the entity manager cache,  myCollection's entities will be updated accordingly, so you don't need to do anything when the executeQueryAsync gets completed.

Regards,

Guillermo



Print Page | Close Window