Hi all,
Really sorry to ask this as im sure its fairly simple once you know.
Im trying to join to datatables using linq and return columns from both tables and then insert the result into another datatable.
The problem is that I cant use the query.CopyToDataTable() method as there are anonymous types in the query (or something). Please see the code below.
I have been looking online now for absolutely ages! I have seen the ObjectShredder class advice given on MSDN but cant quite work it out, and i have tried a huge variety of other potential solutions, alas to no avail.
Could someone please either point out where im going wrong or may be a quick pointer on how to get the ObjectShredder Class to resolve this?
Any help at this stage is more than welcome!
Thanks in advance
Chris
The original bit of code:
Dim query = From a In dt _
Join b In dtLossEvents _
On _
a.Field(Of Integer)("EventID") Equals b.Field(Of Integer)("EventID") _
Select New With { _
a, _
b _
}
This it the latest flawed incarnation:
Dim query = From a In dt _
Join b In dtLossEvents _
On _
a.Field(Of Integer)("EventID") Equals b.Field(Of Integer)("EventID") _
Select New With { _
.Gross_Loss = a.Field(Of Double ("Gross_Loss"), _
.Net_Loss = a.Field(Of Double)("Net_Loss"), _
.EventID = b.Field(Of Integer)("EventID") _
}