MadIce
asked on
Query results to data table
I need to build a table with the results of different LINQ queries. I was trying to do this with a data table but now sure of the syntax. An example of what I'm trying to do is below.
After I add all the columns and create all the other LINQ queries, How do I add/update the data table with the results? Or is there a better way then using a data table? Was I build the table and create calculate columns the end results will end up in an excel spreadsheet.
Using VB 2008 framework 3.5.
Thanks
After I add all the columns and create all the other LINQ queries, How do I add/update the data table with the results? Or is there a better way then using a data table? Was I build the table and create calculate columns the end results will end up in an excel spreadsheet.
Using VB 2008 framework 3.5.
Thanks
Dim ResultsTable as DataTable
Dim dc As New dcDSSDataContext
Dim TMADODList = From TMA In dc.vwCurrentTMA _
Select TMA.DOD
Dim InterChgDODList = From IC In dc.datInterchangeableDOD _
Select IC.DOD
Dim DODList = TMADODList.Union(InterChgDODList )
DODList = DODList.Distinct
ResultsTable = New DataTable("Results")
ResultsTable.Columns.Add("DOD", GetType(String))
ResultsTable.Columns.Add("Location", GetType(String))
'Other columns added here
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also look at this : http://blogs.msdn.com/aconrad/archive/2008/01/11/pathetic-plea-for-help.aspx#7103127
ASKER
I get CopyToDataTable() is not a member of System.Liq.IQueryable(Of String) error. Do I need to add a reference?
I got the datatable to add new rows with the following
For Each DOD in DODList
ResultsTable.Rows.Add(New Object() {DOD})
Next
But how do I update Columns with the results of a different LINQ query? I want to update the second Query?
I got the datatable to add new rows with the following
For Each DOD in DODList
ResultsTable.Rows.Add(New Object() {DOD})
Next
But how do I update Columns with the results of a different LINQ query? I want to update the second Query?