I am trying to return a linq query from a method and am having some trouble determining the return type to this method. I have consulted a few sources and have not had any luck finding a method returns a query joining together multiple tables. The method is as follows:
public static List<Session> SessionQueries()
{
using(var db = new LearningServicesEntities())
{
var query = (from session in db.Sessions
join tuteeStudent in db.Students on session.TuteeStudentID equals tuteeStudent.StudentID
join tutorStudent in db.Students on session.TutorStudentID equals tutorStudent.StudentID
join c in db.Courses on session.CourseID equals c.CourseID
select new {session.Date, session.Time, tuteeStudent.FullName, c.CourseNumber, c.CourseName, session.In, session.Out, session.Office}).ToList();
return query.ToList();
}
}
The query variable in this method does not simply return a list a sessions, however, it returns a list of anonymous types and I do not know how to handle this. I eventually will call this method in the controller to pass the returned data to a view. Any help on this topic would be very much appreciated. Thank you in advance.

New Topic/Question
Reply



MultiQuote





|