I have 3 tables Student, Course, and the linking table StudentCourse, how do i return all the courses given a student Id = 1 but also include row where the student id might not
Given that this is EF and your latest clarification you should have a Courses
navigation property on your Student
entity and a Students
navigation on your Course
entity that would allow you to do the following:
var students = db.Students
.Single(x=> x.Id == 1)
.Courses.SelectMany(c=> c.Students)
.Distinct();