So I have 2 tables Comments and Students. Every comment has a student:
Comment.StudentId
I am using POCO generated classes, and it seems to give me the whole Student object inside the Comment classes when I make a query like so:
var query =
from comment in context.Comments
where comment.StudentId == properId
orderby comment.Created
select comment;
So I can access student properties like so comment.Student.Name
However, when I copy the results (query.ToList() to use outside the method, It gives me an error saying the ObjectContext instance was disposed.
How can I retrieve data from objects contained in objects?
add .Include(“Student”) before .ToList()