TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mark Tabor
548
2k
460.3k
Linq Query Return zero rows how to make left join with linq
Sep 21 2020 2:44 AM
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> Student_Assigned_courses = db.StudentCoursesAssigned.ToList();
List<Courses> courses = db.Courses.ToList();
List<Moduel> Module = db.Moduels.ToList();
List<Years> year = db.Years.ToList();
List<Semesters> semesters = db.Semesters.ToList();
List<Programs> Programs = db.Programs.ToList();
List<Student> students = db.Students.ToList();
List<Courses> curr = db.Courses.ToList();
List<Grade> grade = db.grades.ToList();
IEnumerable<Courses> 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.
Reply
Answers (
11
)
Table display details including timezone in asp.net mvc 5?
WinForm Textbox Values to Ms word template