jam*_*one 0 c# linq linq-to-sql
我有以下LINQ查询.问题是,当tblSurveys总共只有20个时,它会返回13k的结果.我究竟做错了什么?
from s in surveyContext.tblSurveys
from st in surveyContext.tblTypes_for_Surveys
from t in surveyContext.tblSurvey_Types
where (s.Survey_Date >= startDate && s.Survey_Date <= stopDate) &&
(s.Unsubstantiated ||
(st.SurveyID == s.SurveyID && st.SurveyTypeID == t.SurveyTypeID &&
t.UnsubstantiatedAvailable && (from d in surveyContext.tblDeficiencies
where d.SurveyID == s.SurveyID
select d.DeficiencyID).Count() == 0))
orderby s.Survey_Date
select s;
Run Code Online (Sandbox Code Playgroud)
我可以在那里看到一个交叉连接,看看<-------
from s in surveyContext.tblSurveys
from st in surveyContext.tblTypes_for_Surveys
from t in surveyContext.tblSurvey_Types
where (s.Survey_Date >= startDate && s.Survey_Date <= stopDate) &&
(s.Unsubstantiated || <-------
(st.SurveyID == s.SurveyID && st.SurveyTypeID == t.SurveyTypeID &&
t.UnsubstantiatedAvailable && (from d in surveyContext.tblDeficiencies
where d.SurveyID == s.SurveyID
select d.DeficiencyID).Count() == 0))
orderby s.Survey_Date
select s;
Run Code Online (Sandbox Code Playgroud)
看来你需要在这里做左联
| 归档时间: |
|
| 查看次数: |
119 次 |
| 最近记录: |