I have this code:
EmployeeEntities storeDB = new EmployeeEntities();
public ActionResult Index()
{
var employee = storeDB.Employees.ToList() //ToList is not showing up!
return View(employee);
}
and my EmployeeEntities class looks like this:
public class EmployeeEntities : DbContext
{
public DbSet<Employee> Employees { get; set; }
}
Why I cannot see ToList() in my ActionResult Index() ???
Add the namespace where the .ToList() extension method is defined:
using System.Linq;
to the top of your file.
These functions are "Extension Methods", defined in Linq. That's why you need to reference System.Linq regardless of whether you are using Entity Framework or not.
Add the namespace where the .ToList() extension method is defined:
using System.Linq;to the top of your file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With