Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 360
dotnetN00b Avatar asked Nov 25 '25 18:11

dotnetN00b


1 Answers

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.

like image 78
Albin Sunnanbo Avatar answered Nov 28 '25 14:11

Albin Sunnanbo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!