Solved

LINQ query to datatable

Posted on 2009-06-29
2
1,417 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

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

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

864 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now