返回以查看了ToList()不工作 [英] Returning to view as ToList() not working

查看:561
本文介绍了返回以查看了ToList()不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的code:

EmployeeEntities storeDB = new EmployeeEntities();
         public ActionResult Index()
            {
                var employee = storeDB.Employees.ToList() //ToList is not showing up!
                return View(employee);
            }

和我EmployeeEntities类看起来是这样的:

and my EmployeeEntities class looks like this:

 public class EmployeeEntities : DbContext
{
    public DbSet<Employee> Employees { get; set; }
}

为什么我看不到了ToList()在我的ActionResult指数()???

Why I cannot see ToList() in my ActionResult Index() ???

推荐答案

添加命名空间,其中<​​a href=\"http://msdn.microsoft.com/en-us/library/bb342261.aspx\"> .ToList() 扩展方法的定义是:

Add the namespace where the .ToList() extension method is defined:

using System.Linq;

到文件的顶部。

这篇关于返回以查看了ToList()不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆