I have the following LINQ query. The problem is it's returning 13k results when tblSurveys
only has 20 total. What am I doing wrong?
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;