New Posts New Posts RSS Feed: Async Navigational Properties
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Async Navigational Properties

 Post Reply Post Reply
Author
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Topic: Async Navigational Properties
    Posted: 30-Oct-2012 at 5:22pm
How are you checking if the entity is detached? The debugger is not a reliable way to inspect the EntityAspect. Use the Immediate Window to check the entity state.
 
Read the last paragraph in my best practices blog post for advise on navigation properties.
 
Back to Top
LowOrbit View Drop Down
Newbie
Newbie


Joined: 17-Aug-2007
Location: United States
Posts: 20
Post Options Post Options   Quote LowOrbit Quote  Post ReplyReply Direct Link To This Post Posted: 30-Oct-2012 at 4:26pm
This is WPF application. Since I'm using a Repository from Cocktail, all the repository methods do queries ASync. But I have overriden the DefaultEntityReferenceStrategy property and set it to NOT use async when fetching navigational properties.
 
And no, the entity I'm getting back is not a NullEntity because all the fields are populated from the database as I would expect, it's just the EntityState is saying it's Detached.
 
Also, if I fetch my main entity using the Repository and put an Include on it, the related Entity comes back as expected (not a NullEntity) but it is still Detached. It doesn't appear to make any difference whether you get the related entity via an Include or reference it by lazy loading.
 
Ultimately, I want to change my application to fetch all navigational properties using Async also. Unfortunately, we have a lot of UI that is referencing a navigational property in the UI bindings via a path (i.e.     Entity.TaskSchedule.Name). TaskSchedule in this case is a navigational property. When fetched Async, TaskSchedule comes back as a PendingEntity and the binding will show Name as blank initially. I can't seem to get the UI to refresh properly when the PendingEntity is finally complete which is why I switched all the Navigation properties to fetch syncronously.
 
Do you have an example of how to use the Repositories to fetch navigational properties?
 
Thanks!
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 30-Oct-2012 at 3:36pm
Silverlight or WPF? If the former, navigations are always asynchronous and in WPF they are synchronous by default. 



Back to Top
LowOrbit View Drop Down
Newbie
Newbie


Joined: 17-Aug-2007
Location: United States
Posts: 20
Post Options Post Options   Quote LowOrbit Quote  Post ReplyReply Direct Link To This Post Posted: 30-Oct-2012 at 11:40am
Hello
 
I am using the Cocktail framework in our application. I have created a Repository object to perform queries on an entity. For example, I have a simple query that fetches a single entity (uses WithIdAsync). This operation returns successfully. I then try to fetch another record via a navigation property of that entity. I have set the DefaultEntityReferenceStrategy to
 
new EntityReferenceStrategy(EntityReferenceLoadStrategy.Lazy, MergeStrategy.OverwriteChanges, false)
 
which basically tells DevForce to NOT use Async for navigation properties. The problem I'm running into is that any navigation properties fetched this way come back with an EntityState of Detached. Is this really supposed to be the case? Shouldn't any entities fetched via a navigation property come back as Unchanged?
 
Thanks
 
Robert
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down