
Can any body help me to convert the following SQL query in LinqToSql syntax. It involves Multiple tables from my tables. I am not sure if I am using correct Query Type. Any help would be highly appreciated.
public IQueryable<tblCourseNeededHours>(int departmentId, string semester)
{
return from =
"SELECT tblCourseNeededHours.Semester, tblCourseNeededHours.NeededHoursPerWeek,
tblCourseNeededHours.AssignToInstituteAdministrator,
tblCourseNeededHours.Freezed, tblCourse.CourseName,
tblInstitute.InstituteName, tblDepartment.DepartmentName
FROM tblCourseNeededHours
INNER JOIN tblCourse ON
tblCourseNeededHours.CourseID = tblCourse.CourseID
INNER JOIN tblInstitute ON
tblCourse.InstituteID = tblInstitute.InstituteID
INNER JOIN tblDepartment ON
tblInstitute.DepartmentID = tblDepartment.DepartmentID";
}
Well, if you have proper foreign keys in your database you can just do
and so forth.
No need to do any of the inner joins yourself. That is the beauty of Linq2Sql.