I have a single columned datatable inside a single tabled dataset.
I just want to convert this dataset to distinct rows. Here is my code, it gives compile error ‘.’ expected. What am I doing wrong? (I tried adding the ., still same error). I know this is something stupidly obvious. PLZ Save me! 😉
Thanks much in advance!
Dim query = _
From email In ds.Tables(0) _
Select email.Field<string>("Email").Distinct()
EDIT: DOH! MIXING VB/C# SYNTAX HERE! I changed to (Of String) and it works… BUT NOW ‘query’ is an ienumerable collection of characters… not a datatable… so how do I convert back easily without manually doing a loop?? Plz advise!
You are applying the
Distinctmethod to each string, not the result of the query. As strings are collection of character, you can apply extension methods to them too.Put parentheses around the query: