Linq to Datarow, Select multiple columns as distinct?

Posted by Beta033 on Stack Overflow See other posts from Stack Overflow or by Beta033
Published on 2010-04-16T16:18:49Z Indexed on 2010/04/16 16:23 UTC
Read the original article Hit count: 1826

Filed under:
|

basically i'm trying to reproduce the following mssql query as LINQ

SELECT DISTINCT [TABLENAME], [COLUMNNAME] FROM [DATATABLE]

the closest i've got is

Dim query = (From row As DataRow In ds.Tables("DATATABLE").Rows _
                  Select row("COLUMNNAME") ,row("TABLENAME").Distinct

when i do the above i get the error

Range variable name can be inferred only from a simple or qualified name with no arguments.

i was sort of expecting it to return a collection that i could then iterate through and perform actions for each entry. maybe a datarow collection?

As a complete LINQ newb, i'm not sure what i'm missing. i've tried variations on

Select new with { row("COLUMNNAME") ,row("TABLENAME")}

and get:

Anonymous type member name can be inferred only from a simple or qualified name with no arguments.

Also, does anyone know of any good books/resources to get fluent?

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about vb.net