Select two datacolumns from datarow to 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 a violation. Is there any way to do this? I would think that this is easy enough. Obviously, I was wrong ...

+3
source share
1 answer
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 correctly

This returns an anonymous type if you want to return an existing type that you are replacing with Withthis type.

+6
source

Source: https://habr.com/ru/post/1761171/


All Articles