New Posts New Posts RSS Feed: Eager Loading Entire Graph
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Eager Loading Entire Graph

 Post Reply Post Reply
Author
mdcalhoun View Drop Down
Newbie
Newbie


Joined: 12-Aug-2010
Location: Marlboro, NJ
Posts: 4
Post Options Post Options   Quote mdcalhoun Quote  Post ReplyReply Direct Link To This Post Topic: Eager Loading Entire Graph
    Posted: 23-Aug-2010 at 1:48pm
Hello,
 
Is there a way to easily load the entire entity graph for a specific object?
 
For example,
 
Deal has N Deal Versions.
Deal Version has N Price Groups.
Price Group has N Price Items.
Price Item has N Products
 
I'd like to do a single query for a deal that brings back Deal and all children (Version, Price Group, Price Item).
 
Thanks,
Matt
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: 23-Aug-2010 at 6:27pm
Hi Matt,
 
The code should look like this:
 
entityManager.Deals.Where(...)
  .Include("DealVersions")
  .Include("DealVersions.PriceGroups")
  .Include("DealVersions.PriceGroups.PriceItems")
  .Include("DealVersions.PriceGroups.PriceItems.Products")
 
The first path can also be written in a strongly typed manner:
  .Include(Deals.PathFor(deal => deal.DealVersions))
 
However, this doesn't work when navigating through collections, so you have to do the rest by string.
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down