dotnetN00b
dotnetN00b

Reputation: 5131

Select two datacolumns from a datarow in linq (vb.net 3.5)

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....

Upvotes: 3

Views: 9670

Answers (1)

Albin Sunnanbo
Albin Sunnanbo

Reputation: 47048

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.

Upvotes: 6

Related Questions