I am making a page with Linq in C# with MVC but I need a list of completed courses to compare it with the total list of courses to see which ones are missing! I have this code but I only get one
var empleado = db.Employees.Where(x => x.EmployeeID == numReloj).ToList();
var ID = empleado[0].ID;
var employeec = db.Employee_Course.Where(x => x.ID_EMPLEADO == ID).ToList();
var idcourse = employeec[0].ID_CURSO;
var cursos = db.Courses.Where(x => x.ID_CURSO == idcourse).ToList();
var cursor = cursos[0].ID_CURSO;
var cursosjoin = db.Matrices.Where(x => x.ID_CURSO != cursor).ToList();
return View(cursosjoin);
Someone of some option that if I grab all and not just the first!
Since you already have the list of the courses that the employee has taken and the list of courses that exist, all you have to do is search for the courses that the employee has yet to take, you can do this:
With this last query you will obtain the courses that the employee is missing.