New Posts New Posts RSS Feed: Problem with AsyncParallelTask and navigation properties
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Problem with AsyncParallelTask and navigation properties

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

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Topic: Problem with AsyncParallelTask and navigation properties
    Posted: 30-Jun-2010 at 6:14pm
In the process of upgrading to DF2010 6.0.3.1:
I'm having an issue with AsynchParallelTask which is performing a few queries to preload a bunch of tables which are used for navigation properties.  For some reason one of the navigation properties remains "detached" even though the data is there.

In this instance:
      var queryCity = Manager.Cities
                                    .Include(City.PathFor(c => c.County.State.Country));
      var queryLanguage = Manager.Languages.Where(l => l.Enabled);

      int i = 0;
      var task = AsyncParallelTask.Create()
        .AddAsyncQuery(++i, n => queryCity, r => { })
        .AddAsyncQuery(++i, n => queryLanguage, r => { });
      task.Execute(...);

Stepping into the "..." section of code in the Execute(), and inspecting "Manager.States.First()", I see "{Language: 0} - Detached" for the Language navigation property.
If I inspect "Manager.Languages.First()", I see "{Language: 1} - Unchanged", so I know the data is there since the first states should really be linked to Language 1.

If I change the first query to:
      var queryCity = Manager.Cities
                                    .Include(City.PathFor(c => c.County.State.Country))
                                    .Include(City.PathFor(c => c.County.State.Language));
and rerun it.
This time, when I inspect "Manager.States.First()", I see "{Language: 1} - Unchanged" for the navigation property.

I'm going to leave the query in the second case for now, but I'm worried that some other navigation properties may not be linking up correctly during a complex asynch parallel query.

Thanks!


Edited by mikewishart - 30-Jun-2010 at 6:24pm
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 02-Jul-2010 at 6:37am
Hi Mike,
 
Try adding an include for the state (and County if you need it), e.g.:
.Include(City.PathFor(c => c.County.State)
 
In this case, the debugger is not particularly reliable to inspect the state of the system as the debugger's access to the properties itself causes code to execute (since they are not simple properties).  If you suspect odd behavior, try inspecting the entities in code and if still odd, put it in an isolated test case.
 
Let us know what you find!
 
Back to Top
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Posted: 02-Jul-2010 at 10:09am
Hi Ting,

No luck.

      var queryCity = Manager.Cities
                                    .Include(City.PathFor(c => c.County.State.Country))
                                    .Include(City.PathFor(c => c.County.State));
      var queryLanguage = Manager.Languages.Where(l => l.Enabled);

States still do not get linked up to the languages.

The original symptom that caused me to go look for this: When the application starts up it looks at the local configuration, determines what state the user lives in and determines the initial default language.  The language was being set to an empty string.  Looking at this the State and Language were disconnected even though both records were in the entity graph.


Edited by mikewishart - 02-Jul-2010 at 10:09am
Back to Top
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Posted: 02-Jul-2010 at 12:34pm
I created a second application to try and demo this for you, but it's working fine there.  I'll try and figure out what is going on in our main application that is causing this.
Back to Top
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Posted: 02-Jul-2010 at 3:09pm
Apparently this was caused by some sort of corruption in the edmx file when converting from VS2009 to VS2010.

Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 02-Jul-2010 at 6:25pm

Because the edmx's are not compatible from .NET 3.5 to .NET 4.0, developers needed to rebuild the model again for .NET 4.0.  Did you do a conversion by hand?  There were a few gotchas that made this not the recommended path.

Back to Top
mikewishart View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Feb-2010
Location: Reno, NV
Posts: 49
Post Options Post Options   Quote mikewishart Quote  Post ReplyReply Direct Link To This Post Posted: 03-Jul-2010 at 11:50am
Definitely a few gotchas, I tried to do it by hand originally.
After discovering this problem, I went back and started a new application, created new edmx files for our databases and referenced the old edmx files to try in fill in the gaps. Remembering where all the customizations were done on a large model (for example, a column's concurrency strategy set to something other than "none") is the tough part.  The pluralization isn't quite as nice as it was before either. After that was done, it was just a matter of unloading the model project, copying the edmx files in place and reloading the project and regenerating the devforce code.  I hope we don't have to go through that again anytime soon.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down