views:

93

answers:

1
Dim orders = From tt In testTable _
             Order By tt.Item("OrderNumber") _
             Select tt.Item("OrderNumber"), tt.Item("OrderId")

This is breaking. Is there a way to do this? I would have thought it was easy enough. Obviously, I thought wrong....

A: 
Dim orders = From tt In testTable _
     Order By tt.Item("OrderNumber") _
     Select New With {.OrderNo = tt.Item("OrderNumber"), .OrderId = tt.Item("OrderId")}

If I got the VB.NET syntax right

This returns an anonymous type, if you want to return an existing type you replace With with that type.

Albin Sunnanbo
I had a similar solution:Dim projects = From tt In testTable _ Order By tt.Item("ProjectName") _ Select ProjectName = tt.Item("ProjectName"), ProjectId = tt.Item("ProjectId") _ Distinct
dotnetN00b