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

The Archive Base Latest Questions

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

Actually I think I might have fixed it, gonna do some testing, I wll

  • 0

Actually I think I might have fixed it, gonna do some testing, I wll post my solution if it works.

I am migrating an older DB system over to LINQ, I’m having trouble converting a few of the SQL statements though:

SELECT * FROM cities 
INNER JOIN deals ON cities.cityId = deals.CityID 
INNER JOIN countries ON cities.countryID = countries.CountryId 
WHERE deals.endDate >= (someDate) 
   AND countries.CountryId = (1) 
   AND deals.soldout = (false)

I’ve done some research, but I can’t get it to work. Here is the LINQ statement I came up with:

var deals = from d in db.deals
                     join city in db.cities on d.CityID equals city.cityId
                     join country in db.countries on city.countryID equals country.CountryId
                     where d.endDate > DateTime.Today && country.CountryId == 1 && d.soldOut == false
                     select d;

Is there some particular way to use 2 joins in LINQ?

Sorry, I had a formatting error: the statement is meant to select all the deals that have a city who’s countryID = 1

  • 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-22T17:17:24+00:00Added an answer on May 22, 2026 at 5:17 pm

    You do not need the 2nd join if you have a country code for the city…

    var deals = from d in db.deals
                     join city in db.cities on d.CityID equals city.cityId
                     where d.endDate > DateTime.Today &&
                     city.CountryId == 1 && d.soldOut == false
                     select d;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I actually have two questions regarding the same problem but I think it is
On a Linux system, I have one 7MB chunk of memory of fixed size
I don't think this is possible, but thought someone might have a nifty idea
Today I fixed a bug in an application that might have lead to an
I might be wrong about what is actually happening here but i have 3
Does anyone actually think this is a good reason to Dumb down your code?
Let's say, hypothetically (read: I don't think I actually need this, but I am
For some reason my code here (this is the entire thing) doesnt actually render
Actually, this question seems to have two parts: How to implement pattern matching? How
Actually, I'm using this way. Do you have a better way? private bool AcceptJson(HttpRequest

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.