New Posts New Posts RSS Feed: PendingEntityList
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

PendingEntityList

 Post Reply Post Reply
Author
tj62 View Drop Down
Groupie
Groupie
Avatar

Joined: 21-May-2009
Location: Iceland
Posts: 81
Post Options Post Options   Quote tj62 Quote  Post ReplyReply Direct Link To This Post Topic: PendingEntityList
    Posted: 02-Oct-2009 at 9:09am
Hi,
PendingEntityLists seem to be a littl hokus-pokus. I se it working by using the same coding as shown in one of the SilverLight samples. For a second list it is not working however in my SL application....why I don't know as I do not fully understand how it works.
 
The real weakness of DevForce for Silverlight is lack of documentation for the SL-part. I realy get frusturated in between trying to hack me through samples etc. to get things working.
 
Can anyone explain for me how those PendingEntityLists are working as those seem to be pretty clever, not needing to do massive  ExecuteQueryAsync () for "sub-entities".
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 02-Oct-2009 at 11:20am
Silverlight requires all data retrieval to be performed asynchronously.

When you reference a navigation property that returns a collection, e.g., aCustomer.Orders, you are launching a query -- which is necessarily asynchronous.

Therefore DevForce needs a callback method to exercise when the asynchronous retrieval operation is completed. You supply this when you set up a PendingEntityListResolved handler for the aCustomer.Orders property.  That handler then receives the collection of returned child entities via the ResolvedEntities property of its PendingEntityListResolvedEventArgs parameter. Then you take whatever action you wanted to take once those entities were available.

For navigation properties that return a scalar result (single entity, e.g., anOrder.Customer), there is a corresponding event, PendingEntityResolved, which is used in a similar fashion.

-------------------------
Related info: On the EntityManager, there is a property UseAsyncNavigation which determines whether asynchronous data retrieval is used when satisfying references to navigation properties. This property is set to true by default in Silverlight applications; false in other types of applications. If you wanted to write an application with both WPF and Silverlight front ends, you could set this property to true and then write all of your controller logic to perform data operations asynchronously.



Edited by GregD - 02-Oct-2009 at 11:24am
Back to Top
tj62 View Drop Down
Groupie
Groupie
Avatar

Joined: 21-May-2009
Location: Iceland
Posts: 81
Post Options Post Options   Quote tj62 Quote  Post ReplyReply Direct Link To This Post Posted: 03-Oct-2009 at 3:49am
So is it such then that as soon as I set the PendingEntityListResolved it triggers async retrieval of the pending entities?
If so and I need later to reload the entities, how do I trigger that?
 
Second question: In most of the cases this seems to work in my SL-application. However for one particular list (EntPoint.Buildings) it does not seem to work. I set the event handler and the event is fired normaly. However when I try to read the entities (in a foreach( EntBuilding b in e.ResolvedEntities ) loop) the list is empty although there are records in the underlying database. Any idea why this could be?
Back to Top
tj62 View Drop Down
Groupie
Groupie
Avatar

Joined: 21-May-2009
Location: Iceland
Posts: 81
Post Options Post Options   Quote tj62 Quote  Post ReplyReply Direct Link To This Post Posted: 03-Oct-2009 at 5:43am
My third question regarding this: If the pending list has a one2one relation to another Entity. Is it somehow possible to force the load of the related entity when the PendingEntityListResolved event is triggered for the list.

Just to explain better: If I would like to do this in LINQ, I would use the .Include("One2OneRelatedEntity") to load it.
 
Doing a special load for each of the entities in the pending list is quite expensive....so I would like to force inclusion in the PengingEntityListResolved event.
 
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 06-Oct-2009 at 10:26am
Originally posted by tj62

So is it such then that as soon as I set the PendingEntityListResolved it triggers async retrieval of the pending entities?

No. The retrieval is initiated when you make reference to the property.

Originally posted by tj62

Second question: In most of the cases this seems to work in my SL-application. However for one particular list (EntPoint.Buildings) it does not seem to work. I set the event handler and the event is fired normaly. However when I try to read the entities (in a foreach( EntBuilding b in e.ResolvedEntities ) loop) the list is empty although there are records in the underlying database. Any idea why this could be?


Sorry, no.
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 06-Oct-2009 at 10:31am
Originally posted by tj62

My third question regarding this: If the pending list has a one2one relation to another Entity. Is it somehow possible to force the load of the related entity when the PendingEntityListResolved event is triggered for the list.

Just to explain better: If I would like to do this in LINQ, I would use the .Include("One2OneRelatedEntity") to load it.
 
Doing a special load for each of the entities in the pending list is quite expensive....so I would like to force inclusion in the PengingEntityListResolved event.
 


You can always issue your own query for the child entities instead of using the navigation property. On that you can use Include().

Alternatively, it's always faster to preload in bulk; so if you can write a query that will preload the needed related entities before you start iterating through the parents, do that.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down