Group Query Question

jsurpless

Well-known member
Joined
Jul 29, 2008
Messages
144
Programming Experience
Beginner
Hi all

Hoping that someone can help me figure this out...

I believe that the following would be a LINQ "Select" Query?

VB.NET:
Dim Query = From Record In Table.AsEnumerable() Select Record
     Where Record.Field(Of String)("FieldName") = SomeString

With this, I'm able to refer to any field in the table by using

VB.NET:
For each Record In Query

   Record.Field(Of String)("SomeFieldName")

Next Record

However, when I add a 'Group by' statement, I seem to lose this ability... I seem to have to explicitly refer to a field in the query like so

VB.NET:
Dim Query = From Record In Table.AsEnumerable()
     Select MyField = Record.Field(Of String)("FieldName")
              MyField2 = Record.Field(Of String)("FieldName2")
     Where MyField = SomeString

Later in a For loop, I can only refer to MyField via Record.MyField - Record.MyField2 doesn't appear valid...


Can someone shed some light on what I'm doing wrong?

Thanks!

-Justin
 
Back
Top