Solved

Query results to data table

Posted on 2009-06-28
3
312 Views
Last Modified: 2013-11-11
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


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

Open in new window

0
Comment
Question by:MadIce
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 500 total points
ID: 24732988
Think below will guide you in right way:

Creating a DataTable From a Query (LINQ to DataSet) ( http://msdn.microsoft.com/en-us/library/bb386921.aspx  )
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24733008
0
 

Author Comment

by:MadIce
ID: 24733343
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?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question