Print Page | Close Window

Getting Related Parent Entities

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1577
Printed Date: 19-Sep-2025 at 4:32pm


Topic: Getting Related Parent Entities
Posted By: manishaudio
Subject: Getting Related Parent Entities
Date 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);

}

 

}

}




Replies:
Posted By: GregD
Date 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





Print Page | Close Window