Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7787775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:46:40+00:00 2026-06-01T20:46:40+00:00

I can’t seem to access parent child child child. IE. WorkOrder has 1 Unit

  • 0

I can’t seem to access parent child child child. IE. WorkOrder has 1 Unit which has 1 Building which has 1 Site

I’ve been able to eager load the unit, but I can’t seem to get any “deeper”.

Code:

int workOrderId = 1;
var workOrder = context.WorkOrders.Expand("Unit").Where(w => w.Id == workOrderId).First();

string siteId = workOrder.Unit.Building.Site.Id.ToString(); // kaboom (null)

In theory I could eager load the WorkOrder unit, do the same with unit/building and then 1 more time with building to site. But that seems way overboard for what I’m trying to do.

I guess what I want to be able to do is expand all of the children in 1 query.

Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:46:41+00:00Added an answer on June 1, 2026 at 8:46 pm

    So here’s what I’ve found:

    First off, WCF Data Services does not support lazy loading proof. This means that this code will never work:

    var workOrder = context.WorkOrders.First();
    string siteId = workOrder.Unit.Building.Site.Id.ToString(); // won't work w/ WCF Data Services
    

    Then I thought I could use a join like below, however WCF Data Services does not support joins proof:

    var query =
        from wo in context.WorkOrders
        join unit in context.Units on wo.Id equals unit.Id
        join building in context.Buildings on unit.Id equals building.Id
        join site in context.Sites on building.Id equals site.Id
        where wo.Id == workOrderId
        select new 
        {
            SiteId = site.Id,
        };
    

    Finally, after taking a look at the oData specification of expand oData expand I was able to find that my original Expand usage was CLOSE to what I wanted, this works:

    int workOrderId = 1;
    var workOrder = context.WorkOrders.Expand("Unit/Building/Site").Where(w => w.Id == workOrderId).First();
    string siteId = workOrder.Unit.Building.Site.Id.ToString(); // shows site id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
Can a LINQ enabled app run on a machine that only has the .NET
Can someone help me with this scenario? *There is a button, which when tapped,
Can't seem to figure out what's wrong with the simple getJSON call below. It's
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Can anyone help me as what is going wrong here? Am not able to
I have an array which has BIG numbers and small numbers in it. I
Can someone access the database files and/or other files of my app stores in
Can anyone explain why, when I step through my unit tests with the debugger,
Can anyone tell me how I can access to the php.ini file, when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.