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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:23:28+00:00 2026-05-22T16:23:28+00:00

I have this Sql statement SELECT * FROM Game INNER JOIN Series ON Series.Id

  • 0

I have this Sql statement

SELECT * FROM Game 
        INNER JOIN Series ON Series.Id = Game.SeriesId 
        INNER JOIN SeriesTeams ON SeriesTeams.SeriesId = Series.Id 
        INNER JOIN Team ON Team.Id = SeriesTeams.TeamId 
        INNER JOIN TeamPlayers ON TeamPlayers.TeamId = Team.Id 
        INNER JOIN Player ON Player.Id = TeamPlayers.PlayerId 
    WHERE AND Game.StartTime >= GETDATE() 
        AND Player.Id = 1

That I want to be converted into a lambda expression.

This is how it works.

A game can only be joined to 1 series, but a serie can of course have many games. A serie can have many teams and a team can join many series.
A player can play in many teams and a team has many players.

SeriesTeams and TeamPlayers are only the many-to-many tables created by EF to hold the references between series/teams and Teams/Players

Thanks in advance…

Edit: I use the EF 4 CTP5 and would like to have the answer as lambda functions, or in linq if that is easier…

  • 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-05-22T16:23:29+00:00Added an answer on May 22, 2026 at 4:23 pm

    Ok, first of all, if you want to make sure that everything is eager-loaded when you run your query, you should add an explicit Include:

    context.
    Games.
    Include(g => g.Series.Teams.Select(t => t.Players)).
    Where(g => 
             g.StartTime >= DateTime.Now && 
             g.Series.Teams.Any(t => t.Players.Any(p => p.Id == 1))).
    ToList();
    

    However, as I mentioned in my comment, this won’t produce the same results as your SQL query, since you don’t filter out the players from the child collection.

    EF 4.1 has some nifty Applying filters when explicitly loading related entities features, but I couldn’t get it to work for sub-sub-collections, so I think the closest you can get to your original query would be by projecting the results onto an anonymous object (or you can create a class for that if you need to pass this object around later on):

    var query = context.
                Games.
                Where(g =>
                         g.StartTime >= DateTime.Now && 
                         g.Series.Teams.Any(t => t.Players.Any(p => p.Id == 1))).
                Select(g => new
                            {
                                Game = g,
                                Players = g.
                                          Series.
                                          Teams.
                                          SelectMany(t => t.
                                                          Players.
                                                          Where(p => p.Id == user.Id))
                            });
    

    Then you can enumerate and inspect the results:

    var gamesAndPlayersList = query.ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have sql statement like this SELECT DISTINCT results_sp_08.material_number FROM results_sp_08 INNER JOIN courses
I have this sql statement: SELECT game.game_id FROM game, userGame WHERE userGame.user_id = 1
I have this very simple sql statement: SELECT max_dose FROM psychotropes WHERE (patient_meds.psychotrope =
If i have a parameterized SQL statement like this: SELECT * FROM table WHERE
I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0;
i have this sql statement in access: SELECT * FROM (SELECT [Occurrence Number], [1
I have this working SQL statement: select oriseqs.newID from oriseqs WHERE oriseqs.singlets=1 AND oriseqs.newID
I have this SQL statement: SELECT * FROM converts WHERE email='myemail@googlemail.com' AND status!='1' ORDER
I have this sql statement SELECT userID from users WHERE (name='name1' AND username='username1') OR
Okay, so I have this T-SQL statement: SELECT COUNT(DISTINCT RentalNo) as Count FROM RoomRental

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.