1
我想知道寫這樣的查詢的正確方法:正確的方式來寫實體框架查詢
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;
我基本上要選擇一切從問題表,其中它在不同的表中的值相匹配。
我認爲這也有可能寫出像這樣的查詢:
var questions = from q in db.Questions
where q.SurveyQuestions.SurveyID == 1
orderby q.SurveyQuestions.Order
select q;
什麼:
var questions = from q in db.Questions
from sq in q.SurveyQuestions
where sq.SurveyID == 1
orderby sq.Order
select q;
此查詢不工作,而是沿着我怎麼想的線條更正確的方式來使用導航屬性在實體框架中編寫這些類型的查詢?
是的,這可能是更多的沿線,我正在尋找。我會試試這個。 – Dismissile 2010-12-17 20:25:02