Print Page | Close Window

EntityReferenceBase.Load within a coroutine

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=2327
Printed Date: 16-Apr-2025 at 2:36am


Topic: EntityReferenceBase.Load within a coroutine
Posted By: bebe
Subject: EntityReferenceBase.Load within a coroutine
Date Posted: 22-Nov-2010 at 5:16am
I use
manager.UseAsyncNavigation = true
;
manager.DefaultQueryStrategy = QueryStrategy.CacheOnly;

and call
EntityReferenceBase.Load(MergeStrategy mergeStrategy) to load a related entity.

In NorthwindDB this could look like:

var reference = Territory.PropertyMetadata.Region.GetEntityReference(territory);
reference.Load(MergeStrategy.PreserveChanges);


I would like to do this within a coroutine. How can I get informed that the operation is completed (e.g. the Region of the Territory is loaded)?

It would be great if EntityReferenceBase.Load(...) would return a INotifyCompleted. Are there any plans for this feature?





Replies:
Posted By: sbelini
Date Posted: 30-Nov-2010 at 12:23pm
Hi bebe,
 
Unfortunatelly, you won't be able to accomplish that with EntityReferenceBase.Load in a coroutine.
 
Is there any particular reason you are using EntityReferenceBase.Load instead of EntityRelationQuery?
You'll be able to complete the same task using EntityRelationQuery with the plus of being able to use it in a coroutine.
 
For instance:
 
  ...
  var regionERQuery = new EntityRelationQuery(territory, EntityRelations.FK_Territory_Region.ToRole2Link);
  var regionQuery = regionERQuery
    .With(myQueryStrategy)
    .ExecuteAsync();
  yield return regionQuery;
  ...
 
Regards,
   sbelini.



Print Page | Close Window