【发布时间】:2014-05-27 12:37:45
【问题描述】:
我有一个 ASP.NET MVC 应用程序。假设我有这样的看法:
@model IEnumerable<MyClass>
.....
在服务器端,我使用 EF 对我的数据库进行 linq 查询:
public ActionResult Index()
{
var query = from t in context.MyClass
select t;
//now comes the question
return View(query);
return View(query.AsEnumerable()); //is there any difference?
}
我认为 AsEnumerable() 不是必需的,因为查询会自动转换为它,所以,有人可以解释一下 AsEnumerable() 什么时候有用吗?
谢谢!
【问题讨论】:
标签: asp.net-mvc linq entity-framework