System.Collections.Generic.IEnumerable'不包含任何定义'了ToList“ [英] System.Collections.Generic.IEnumerable' does not contain any definition for 'ToList'

查看:1858
本文介绍了System.Collections.Generic.IEnumerable'不包含任何定义'了ToList“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是问题所在。我自ViewPage越来越IEnumerable和当我试图转换列表它显示我像错误:

Here is the problem. I am getting IEnumerable from ViewPage and when I tried it to convert List it is showing me error like:

System.Collections.Generic.IEnumerable< Pax_Detail> '不包含
  对于'了ToList',没有扩展方法'了ToList'接受的一个定义
  类型的第一个参数
   System.Collections.Generic.IEnumerable< Pax_Detail> '可以找到
  (是否缺少using指令或程序集引用?)

'System.Collections.Generic.IEnumerable<Pax_Detail>' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'System.Collections.Generic.IEnumerable<Pax_Detail>' could be found (are you missing a using directive or an assembly reference?)

下面是我的控制器code:

Here is my controller code:

[HttpPost]
public ActionResult Edit_Booking(Booking model, IEnumerable<Pax_Detail> pax)
{
  List<Pax_Detail> paxList = new List<Pax_Detail>();
  paxList = pax.ToList(); //getting error here
  BookingDL.Update_Booking(model, paxList);
  return View();
}

我还有一个控制器上应用相同的逻辑。而且这是工作的罚款。我不知道有什么样的问题。我已经清理,改造项目也重新启动我的笔记本电脑(虽然它需要)。

I have applied same logic on another controller. And it is working fine. I don't know what problem it has. I have already clean, rebuild project and also restarted my laptop(though it was needed).

推荐答案

您缺少using指令为 System.Linq的

Are you missing a using directive for System.Linq?

<一个href=\"http://msdn.microsoft.com/en-us/library/bb342261.aspx\">http://msdn.microsoft.com/en-us/library/bb342261.aspx

这篇关于System.Collections.Generic.IEnumerable'不包含任何定义'了ToList“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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