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 9209821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:56:08+00:00 2026-06-18T00:56:08+00:00

Still pretty new to entity framework. So forgive me if this is a noob

  • 0

Still pretty new to entity framework. So forgive me if this is a noob question. Hoping someone can shed some light on this.

I am trying to select data from 3 related tables.

Leagues -> Teams -> Rosters -> 

The relationships are League.LeagueID => Team.LeagueID => Roster.TeamID

In the Roster table there is a PlayerID column

I need a query that can select all leagues where Roster has PlayerID = 1

I cannot seem to filter results on the grandchild record no matter what I try. Not finding too much on the internet either.

I have found a way to do this with anonymous types but those are read only so i can make changes to the data. I must be able to update the data after it returns.

  • 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-18T00:56:10+00:00Added an answer on June 18, 2026 at 12:56 am
    db.Leagues.Where(l => l.Teams.Any(t => t.Roster.PlayerID == 1));
    

    The SQL generated should get you what you want, even it looks unreadable 😉

    If you want to specifically use inner joins to do this, you can do so with code like this:

    from l in db.Leagues
    join t in db.Teams on l.LeagueID equals t.LeagueID
    join r in db.Rosters on t.TeamID equals r.TeamID
    where r.PlayerID = 1
    select l
    

    UPDATE

    To do with with eager loading the child associations use Include():

    ((from l in db.Leagues
    join t in db.Teams on l.LeagueID equals t.LeagueID
    join r in db.Rosters on t.TeamID equals r.TeamID
    where r.PlayerID = 1
    select l) as ObjectQuery<League>).Include(l => l.Teams.Select(t => t.Rosters))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im still pretty new so bear with me on this one, my question(s) are
Okay this is my 4th question today on Scheme, still pretty new to Scheme,
Still pretty new to ObjectiveC and Cocoa here. Hopefully the answer to this question
I'm still pretty new to Objective-C coding (as evidenced by this question) and I
I am still pretty new to jQuery, so forgive me if this doesn't make
I'm still pretty new to programming so I have somewhat of a noob question.
I am still pretty new to PHP so forgive me if I am overlooking
Question ONE: I'm still pretty new to .net, but have used Visual Studio for
Im still pretty new to NHibernate.Search so please bear with me if this is
I'm still pretty new to javaScript/jQuery, so I'm sorry if this seems elementary. 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.