5
Answers

Issue on use where condion in mvc 4 with entity frameworkk

Ram Pradeep

Ram Pradeep

9y
382
1
Actually i am trying to get the employees information based on the deptno.
 
My Tables:
1.tblemployee2-->colomns-->Id,name,email,sal,deptid
 
2.tbldept2-->colomns-->deptid,deptname.
 
 
here 2 tables has the relation with foreign key constraint.
 
 
now i want to retrieve employee names whose deptid is matching with deptid of tbldept2 table.I am getting error in controller
public class employeeController : Controller
{
//
// GET: /employee/
public ActionResult Index(int id)
{
employeecontext empcontext = new employeecontext();
employee emplist = empcontext.employees.Where(emp => emp.DEPTID == id);
return View(emplist);
}
public ActionResult Details()
{
employeecontext employeecontext = new employeecontext();
List<employee> empnames= employeecontext.employees.ToList();
return View(empnames);
}
}
 
solve this ..... 
Answers (5)