There is no way to do this. Worse: in SQL it might be possible to fetch the subjects with an IN
clause, but with linq you haven't even got that option. I'm afraid what's left is a painstaking linq-to-objects operation where you first grab the Student
from the database, then parse the subjects in an int
array, and finally grab the Subject
s with a Contains
query:
var subjectIds = student.Subjects
.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Select (x => int.Parse(x));
var subjects = context.Subjects.Where(s => subjectIds.Contains(s.Id));
(And don't forget to send the architect as student to a course with subject 'Data base design')