Hi i am facing a problem with my Linq query i have the following table
the issue is i am getting zero rows and when i inspect and bebug the query it says "Enumeration yielded no results"
below is my index method
- public ActionResult Index()
- {
- ViewBag.PopulateGrades = _IEducation.PopulateGrade();
- ViewBag.PopulatePrograms = _IEducation.PopulatePrograms();
- ViewBag.PopulateStudents = _IEducation.PopulateStudents();
- ViewBag.PopulateCourses = _IEducation.PopulateCourses();
- ViewBag.PopulateModules = _IEducation.PopulateModules();
- ViewBag.PopulateYear = _IYear.PopulateYears();
- var StudentVSCourses = db.StudentCoursesAssigned.ToList();
- ViewBag.Block_Id = new SelectList(db.Blocks, "Id", "Name");
- ViewBag.Semester_Id = _ITeacherCoruses.PopulateSemsters();
- using (DatabaseContext db = new DatabaseContext())
- {
- List
Student_Assigned_courses = db.StudentCoursesAssigned.ToList(); - List
courses = db.Courses.ToList(); - List
Module = db.Moduels.ToList(); - List
year = db.Years.ToList(); - List
semesters = db.Semesters.ToList(); - List
Programs = db.Programs.ToList(); - List
students = db.Students.ToList(); - List
curr = db.Courses.ToList(); - List
grade = db.grades.ToList(); - IEnumerable
h = db.Courses.ToList(); - var employeeRecord = from e in Student_Assigned_courses
- join d in students on e.Student_id equals d.Student_Id into table1
- from d in table1.ToList()
- join i in courses on e.Course_Id equals i.Course_Id into table2
- from i in table2.ToList()
- join m in Module on e.Module_Id equals m.Id into table3
- from m in table3.ToList()
- join y in year on e.Year_Id equals y.Id into table4
- from y in table4.ToList()
- join p in Programs on e.Program_Id equals p.Id into table5
- from p in table5.ToList()
- join g in grade on e.Grade equals g.Id into table6
- from g in table6.ToList()
- join s in semesters on e.Semster_Id equals s.Semester_Id into table7
- from s in table7.ToList()
- select new StudentCoursesViewModel
- {
- studentAssignedCourses = e,
- courses = i,
- programs = p,
- //curses=curr,
- curses = h,
- semester = s,
- studnets = d,
- Year = y,
- Modules = m,
- grade = g,
- };
- return View(employeeRecord.ToList());
- }
if i comment the yellow highlighted section than it returns the rows , can someone tell me how to adjust the linq query so that it should return the rows no matter even if the semester is null.
Mark TaborPosted Sep 23, 2020, 1:17 AM
Junaid MuslaPosted Sep 23, 2020, 1:01 AM
Mark TaborPosted Sep 23, 2020, 12:19 AM
Jignesh Kumar I checked the link but i cannot re-write it correctly can you check>
Jignesh KumarPosted Sep 22, 2020, 11:22 PM
Jignesh KumarPosted Sep 22, 2020, 11:20 AM
Mark TaborPosted Sep 22, 2020, 9:07 AM
Mark TaborPosted Sep 22, 2020, 9:05 AM
Jignesh KumarPosted Sep 22, 2020, 7:08 AM
Mark TaborPosted Sep 22, 2020, 5:49 AM
Nisha RegilPosted Sep 21, 2020, 8:54 AM
Jignesh KumarPosted Sep 21, 2020, 4:03 AM