0

I am a C# lover, and not very familiar with VB.NET. I am trying to do a classic:

var data = data.Select(c=>c.Id).ToList()

However, when I do this in VB.NET

<% rModel.SearchProductIds = Model.Products.[Select](Function(c) c.Id).ToList()%>

I get the following error:

"Select is not a member of System.Collections.Generic.List"

I don't understand why. My framework is .NET 3.5, so it should work.

Is it a syntax mistake?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Lars Holdgaard
  • 9,496
  • 26
  • 102
  • 182

1 Answers1

2

You probably need to

@Imports System.Linq

in your view.

Or perhaps more appropriately, add a property to your model that retrieves your product IDs instead of doing that right in the view.

If you use Linq a lot and don't want to add the @Imports statement repeatedly, follow the answer here to have it automatically imported to all of your views.

Community
  • 1
  • 1
Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194