Print Page | Close Window

Coroutine and navigation property retrieval

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=2853
Printed Date: 28-Oct-2025 at 7:13am


Topic: Coroutine and navigation property retrieval
Posted By: JoschaMetze
Subject: Coroutine and navigation property retrieval
Date Posted: 28-Jul-2011 at 1:47am

Hi folks,

is there a way to retrieve a pending navigation property entity in a coroutine without just requerying the entity itself?

My situation is the following:

Entity A has a navigation property B

Entity A is loaded and property B is needed inside a serial coroutine.

I didn't find any method to return the necessary  IEnumerable<INotifyCompleted> for my navigation property. Using the PendingEntityResolved event doesn't help much in a coroutine as it breaks the serial flow.

Any ideas?

Kind regards

Joscha




Replies:
Posted By: smi-mark
Date Posted: 28-Jul-2011 at 8:11am
Could you use an Include in your original query?

Or could you do something like this in your other coroutine?

EntityQuery<EntityB>.Where(b => b.EntityAId = 123)

This will bring it into cache so you can then do A.B


Posted By: JoschaMetze
Date Posted: 28-Jul-2011 at 8:21am

Hi,

unfortunately I cannot use Include as the Entity is queried in another place where I don't know if I will need my navigation property (and even worse, with an EntityKeyQuery).

Of course I could use a Query but that was what I was trying to avoid in the first place cause it seems rather unclean as I am coupling my entities in code and need to have knowledge of the child/parent relationship.

I wouldn't even need a navigation property for that, so the short answer would be no navigation properties in coroutines without making assumptions about them being fetched beforehand.

But I will have to stick to that if there is no sugar coat solution :).

Thanks and regards

Joscha



Posted By: kimj
Date Posted: 28-Jul-2011 at 11:12am
Unfortunately there's no sugar coated solution within DevForce itself :).  I'm not sure why the PendingEntity resolution doesn't implement INotifyCompleted, but another option, albeit with even more work than the above, is to create your own "Operation" class which implements INotifyCompleted and wraps the retrieval and event handling for the pending entity.  There are a few examples of custom operations in the IdeaBlade Application Framework available at http://devforcecaliburn.codeplex.com/ - http://devforcecaliburn.codeplex.com/ , specifically the XapDownloadOperation there is a good example of a custom operation.



Print Page | Close Window