Filter data using LinQ to Object (Expression)
I have 3 tables: Students - Standards - Teachers.
Standards (StandardId) and Teachers (StandardId) has one-many relationship. And also Standards (StandardId) - Students (StandardId)
when I join 3 tables. And I filter column Description which is in Standards table, All ok.
But I add a condition into where, It occur Error.
--- Query:
Students.Join(Standards,s=>s.StudentID,st=>st.StandardId,(s,st)=>new{s.StudentName,st.Description,st.StandardId}).Join(Teachers,a=>a.StandardId,t=>t.StandardId,(a,t)=>new{a.StudentName,a.Description,t.TeacherName}).Where(a=>a.Description.Contains("Toan") && t=>t.TeacherName.Contains("Dai"))
--- And Error:
) or end of expression expected
Invalid expression term '=>'
; expected
Invalid expression term ')'
How can I do ?
Help me, Thanks.
Standards (StandardId) and Teachers (StandardId) has one-many relationship. And also Standards (StandardId) - Students (StandardId)
when I join 3 tables. And I filter column Description which is in Standards table, All ok.
But I add a condition into where, It occur Error.
--- Query:
Students.Join(Standards,s=>s.StudentID,st=>st.StandardId,(s,st)=>new{s.StudentName,st.Description,st.StandardId}).Join(Teachers,a=>a.StandardId,t=>t.StandardId,(a,t)=>new{a.StudentName,a.Description,t.TeacherName}).Where(a=>a.Description.Contains("Toan") && t=>t.TeacherName.Contains("Dai"))
--- And Error:
) or end of expression expected
Invalid expression term '=>'
; expected
Invalid expression term ')'
How can I do ?
Help me, Thanks.
Comments
It also looks like you're making this much harder than it needs to be. See https://www.linqpad.net/WhyLINQBeatsSQL.aspx and read the section "Associations".