This seems like it ought to work. In this code, intellisense has underlined "d_row.Field(Of String)" and flagged it with the warning:
'Field' is not a member of 'sites'.
So that means it is not recognizing 'Field' as a LINQ operator, it thinks I am trying to access a field named 'Field'.
What is my error?
The goal is to use LINQ to select a distinct column from a list of objects and place it in a list(of string).
Code:Public Class sites Public Property Name As String Public Property Location As String Public Sub New(n As String, l As String) Name = n Location = l End Sub End Class Module Module1 Sub Main() Dim sitelist As New List(Of sites) For Each i As String In {"one", "one", "two", "three"} Dim site As sites = New sites(i, "test") sitelist.Add(site) Next Dim siterow As List(Of String) = (From d_row In sitelist.AsEnumerable() Select d_row.Field(Of String)("Name") Distinct).ToList End Sub End Module




Reply With Quote
