I want to know the proper way to write a query like this:
var questions = from q in db.Questions
join sq in db.SurveyQuestions on q.QuestionID = sq.QuestionID
where sq.SurveyID == 1
orderby sq.Order
select q;
I basically want to select everything from the Questions table where it matches a value in a different table.
I think it's also possible to write the query like so:
var questions = from q in db.Questions
from sq in q.SurveyQuestions
where sq.SurveyID == 1
orderby sq.Order
select q;
This query does not work but is more along the lines of how I am thinking:
var questions = from q in db.Questions
where q.SurveyQuestions.SurveyID == 1
orderby q.SurveyQuestions.Order
select q;
What is the right way to write these types of queries in entity framework using the navigation properties?