locked
IEnumerable<Item> does not contain a definition for select .NET FrameWork 4.8 RRS feed

  • Question

  • User457850011 posted

    I have an  mvc 5 razor view  code running on .Net FrameWork 4.5.2 which works fine. Now we are upgrading to the .Net FrameWork 4.8 and I am getting an error "IEnumerable<Item> does not contain a definition for select". Below is the code.

    @model IEnumerable<Items>

    @Html.Partial(ItemActionNames.ListTablePartial, Model.Select(x => new ItemTables(x)))

    Any help will be appreciated.

    Tuesday, July 21, 2020 3:02 PM

Answers

  • User457850011 posted

    Hi 

    I have finally resolved it myself. I was missing reference to System.Core. Added reference to the .csproj file

    <Reference Include="System" />
    <Reference Include="System.Core" />
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 22, 2020 12:59 AM

All replies

  • User-474980206 posted

    you need using statement for linq. most likely your old project specified default using statements. se:

      https://stackoverflow.com/questions/14101065/add-my-project-namespace-to-mvc-web-config

     

    Tuesday, July 21, 2020 3:24 PM
  • User457850011 posted

    Hi bruce

    Thanks for your response. I have added the Name space as per the link above

    <add namespace="myproject.namespace" />

    <add namespace="System.Linq" />

    and still getting 


    'IEnumerable<Items>' does not contain a definition for 'Select' and no accessible extension method 'Select' accepting a first argument of type
    'IEnumerable<Items>' could be found (are you missing a using directive or an assembly reference?)

    Tuesday, July 21, 2020 4:49 PM
  • User457850011 posted

    Hi 

    I have finally resolved it myself. I was missing reference to System.Core. Added reference to the .csproj file

    <Reference Include="System" />
    <Reference Include="System.Core" />
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 22, 2020 12:59 AM