hi,
I am trying to join two datatables using LINQ. I am unable to use .CopyToDataTabl e in my code. I have added System.Data.Dat aSetExtensions. dll. It gives me the error, 'CopyToDataTabl e' is not a member of 'System.Collect ions.Generic.IE numerable(Of <anonymous type>)'.
I have searched online a lot about this. The solution was to add the dll which I did but still I get the error.
Also there are few suggestions for LINQ to datatable which are very huge. I would like to keep it simple. I am not sure, why the CopyToDataTable would not work for me.
here is my code, thank you for your time.
I am trying to join two datatables using LINQ. I am unable to use .CopyToDataTabl e in my code. I have added System.Data.Dat aSetExtensions. dll. It gives me the error, 'CopyToDataTabl e' is not a member of 'System.Collect ions.Generic.IE numerable(Of <anonymous type>)'.
I have searched online a lot about this. The solution was to add the dll which I did but still I get the error.
Also there are few suggestions for LINQ to datatable which are very huge. I would like to keep it simple. I am not sure, why the CopyToDataTable would not work for me.
here is my code, thank you for your time.
Code:
Dim dt2 As New DataTable
dt2.Load(dr2)
Dim dt3 As New DataTable
dt3.Load(dr3)
Dim ds As New DataSet
Dim joinquery = From t1 In dt2.AsEnumerable() Join t2 In dt3.AsEnumerable() _
On t1.Field(Of Decimal)("CLASS_NUMBER") Equals t2.Field(Of Decimal)("CLASS_NUMBER") _
Select New With _
{Key .CLASS_NUMBER = t1.Field(Of Decimal)("CLASS_NUMBER"), _
Key .FACULTY_START_DT = t2.Field(Of DateTime)("FACULTY_START_DT"), _
Key .FACULTY_END_DT = t2.Field(Of DateTime)("FACULTY_END_DT"), _
}
ds = joinquery
NewDg.DataSource = ds
NewDg.DataBind()