?
Solved

LINQ query to datatable

Posted on 2009-06-29
2
Medium Priority
?
1,425 Views
Last Modified: 2013-11-11
I'm using VB 2008
I want to do some Linq queries and the result convert to datatable to use in a datagridview.
If I dothe Option 1 (see the code) it works well, but I have to declare the Linq Query as a System.Data.EnumerableRowCollection(Of ..)

If I declare the Linq query as    IEnumerable it do the query well but then I can't convert it to datatable.      
''Option 1
            Dim Comp053 As System.Data.EnumerableRowCollection(Of LOGDataSet.MovRow)
            Dim tabMovFac As LOGDataSet.MovDataTable
 
            Comp053 = From f In tabMovFac.AsEnumerable _
                       Where (f.TipoFactura <> "I")
            
 
	    Dim taulaComp053 As DataTable
            taulaComp053 = New DataTable
 
            If Comp053.Count > 0 Then
                taulaComp053 = Comp053.AsEnumerable.CopyToDataTable
            End If

Open in new window

0
Comment
Question by:cpx_Support
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 total points
ID: 24735020
I usually code my own methods naming them such as ShredContacts etc. Within these methods, i iterate through the query and manually create datatable. It also helps with things like adding the name of the emp who created the client rather than the ID or the object.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

718 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