Somejerk
Somejerk

Reputation: 193

Simple Linq to List(of T)

I trying to do what seems to be a simple thing but I'm having problems. The answers I find aren't working. I'm still getting casting exceptions:

Dim query = (From l In dePhl.cv_phil Where l.batch = strMmddyyyy
Select l.zipfile.Distinct)
Dim objFileList As List(Of String) = query.ToList() 'Error

Error:

Value of type 'System.Collections.Generic.List(Of System.Collections.Generic.IEnumerable(Of Char))' cannot be converted to 'System.Collections.Generic.List(Of String)'

It seems to work for other people! What am I doing wrong?

Upvotes: 1

Views: 141

Answers (1)

JaredPar
JaredPar

Reputation: 754763

It looks like you want a distinct list of String values. If that's the case then your use of use of Distinct is incorrect because your picking distinct Char values from every String. Try the following

Dim query = (From l In dePhl.cv_phil Where l.batch = strMmddyyyy
Select l.zipfile)
Dim objFileList As List(Of String) = query.Distinct().ToList()

Upvotes: 2

Related Questions