Solved

LINQ query to datatable

Posted on 2009-06-29
2
1,419 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
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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