Print Page | Close Window

PendingEntityList

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1507
Printed Date: 21-Sep-2025 at 10:11pm


Topic: PendingEntityList
Posted By: tj62
Subject: PendingEntityList
Date 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".



Replies:
Posted By: GregD
Date 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.

file:///C:%5CDOCUME%7E1%5CGreg%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml -


Posted By: tj62
Date 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?


Posted By: tj62
Date 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.
 


Posted By: GregD
Date 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.


Posted By: GregD
Date 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.



Print Page | Close Window