Mark Tabor

Mark Tabor

  • 569
  • 1.9k
  • 431.2k

how to get related data from second table based on the value of first

Nov 4 2020 4:48 AM
I have two tables student_courses and student table 
 student_ID Email NAme Password
 1 [email protected] TABOR 123123
 2 [email protected] MARK 123123
 Second I have student Courses table 
 id    student_ID course_Id yearprogram
 1 1 1 12
 2 1 2 1 2
 
now i want to get the  email of all students who is having year 1 and program 2 below is my code by which i am getting data from student courses table , but it did not have email , email field is in student table how to achieve that .
return std.Student_courses.Where(x => x.Program_Id == program && x.Year_Id == year  ).ToList();

Answers (4)