New Posts New Posts RSS Feed: Refreshing Entity
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Refreshing Entity

 Post Reply Post Reply
Author
jipock View Drop Down
Newbie
Newbie
Avatar

Joined: 08-Dec-2010
Location: Cherry Hill, NJ
Posts: 39
Post Options Post Options   Quote jipock Quote  Post ReplyReply Direct Link To This Post Topic: Refreshing Entity
    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?
Back to Top
gkneo View Drop Down
Newbie
Newbie
Avatar

Joined: 23-Jun-2010
Posts: 21
Post Options Post Options   Quote gkneo Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down