New Posts New Posts RSS Feed: Getting Related Parent Entities
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Getting Related Parent Entities

 Post Reply Post Reply
Author
manishaudio View Drop Down
Newbie
Newbie


Joined: 24-Nov-2009
Posts: 8
Post Options Post Options   Quote manishaudio Quote  Post ReplyReply Direct Link To This Post Topic: Getting Related Parent Entities
    Posted: 08-Dec-2009 at 9:48am
I have an application that has the following hierarchy - Locations --> Buildings --> Rooms --> Assets.  I am creating a datagrid with all assets and need to display the room, building, location as well.   Currently, I am having issues getting the Building and Location when I populate assets.  I was able to get the Room data using the Include method on my query.  Here is my code snippet.  
 

private void LoadData()

{

// _mgr.ExecuteQueryAsync(_mgr.Rooms, GotRooms, null);

// _mgr.ExecuteQueryAsync(_mgr.Buildings, GotBuildings, null);

_mgr.ExecuteQueryAsync(_mgr.Assets.Include("Room"), GotAssets, null);

}

private void GotAssets(EntityFetchedEventArgs args)

{

if (args.Error != null)

{

WriteMessage(args.Error.Message);

}

else

{

foreach (Asset asset in args.Result)

{

_assets.Add(asset);

}

 

}

}

Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 08-Dec-2009 at 5:30pm
Originally posted by manishaudio

_mgr.Assets.Include("Room")



_mgr.Assets.Include("Room.Building.Location") will bring the entire object graph into the cache


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down