VB Net - LINQ查询到数据表

时间:2017-11-21 15:35:43

标签: vb.net datatable

我需要传递LINQ结果(currentDetailRow)我正在循环到数据表中。我似乎只能通过单独传递LINQ结果值而不是currentDetailRow作为一个整体,因为它是一个不同的类型。这应该是简单和常见的,我环顾四周,只能找到比传递每个值更复杂的解决方案。但这将是维护痛苦,必须通过代码在许多不同的地方添加新列。

Dim detailQuery = From detailCursor In dtCsvData
                  Select OrderNo = detailCursor.Field(Of Integer)("OrderNo"),
                         LineNo = detailCursor.Field(Of Integer)("LineNo"),
                         Style = detailCursor.Field(Of String)("Style"),
                         SizeDesc = detailCursor.Field(Of String)("SizeDesc"),
                         Colourway = detailCursor.Field(Of String)("Colourway"),
                         Quantity = detailCursor.Field(Of Integer)("Quantity")
                  Where OrderNo = currentOrderLine.OrderNo
                  Where LineNo = currentOrderLine.LineNo
                  Where Style = currentOrderLine.Style

For Each currentDetailRow In detailQuery

    dtPLMOrderDetailData.Rows.Add(currentDetailRow.OrderNo,
                                  currentDetailRow.LineNo,
                                  currentDetailRow.SizeDesc,
                                  currentDetailRow.Colourway,
                                  currentDetailRow.Quantity)

   ' But want something like this!
   ' dtPLMOrderDetailData.Rows.Add(currentDetailRow)

Next

0 个答案:

没有答案