System.Collections.Generic.IEnumerable' does not contain any definition for 'ToList'

前端 未结 5 2047
礼貌的吻别
礼貌的吻别 2020-12-05 09:21

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.Collection

相关标签:
5条回答
  • 2020-12-05 09:41

    Are you missing a using directive for System.Linq?

    http://msdn.microsoft.com/en-us/library/bb342261.aspx

    0 讨论(0)
  • 2020-12-05 09:45

    You're missing a reference to System.Linq.

    Add

    using System.Linq
    

    to get access to the ToList() function on the current code file.


    To give a little bit of information over why this is necessary, Enumerable.ToList<TSource> is an extension method. Extension methods are defined outside the original class that it targets. In this case, the extension method is defined on System.Linq namespace.

    0 讨论(0)
  • 2020-12-05 09:45

    I was missing System.Data.Entity dll reference and problem was solved

    0 讨论(0)
  • 2020-12-05 09:49

    In my case, I had copied some code from another project that was using Automapper - took me ages to work that one out. Just had to add automapper nuget package to project.

    0 讨论(0)
  • 2020-12-05 09:52

    An alternative to adding LINQ would be to use this code instead:

    List<Pax_Detail> paxList = new List<Pax_Detail>(pax);
    
    0 讨论(0)
提交回复
热议问题