none
Using LINQ in VB.NET 2005 Express RRS feed

  • Question

  • I'm using    VB.NET 2005   Express Edition with  Microsoft .NET Framework 2.0.50727 SP2.  I need to run LINQ ...Anybody to help me with enabling  LINQ  on my  2005 VB.NET Express. Thanks in advance

    
    
    
    
    
    
    
    Monday, November 13, 2017 4:52 PM

All replies

  • Hello,

    LINQ started with Visual Studio 2008 so this means you need Visual Studio 2008 at the least.

    EDIT: If you were using C# in Visual Studio 2005 the following would be an option.

    https://www.codeproject.com/Articles/26202/Poor-Man-s-LINQ-in-Visual-Studio


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Monday, November 13, 2017 6:01 PM
    Moderator
  • In addition to Karen,

    Linq before Erik Meijer was a disaster. 

    Erik was not really a Microsoft guy, but when he met VB he introduced the phrase "I love VB".

    He redesigned Linq to what it is currently, before that (versions in 2005) where all kind of isles which had not any mean thing beside the name Linq. 

     


    Success
    Cor

    Monday, November 13, 2017 6:15 PM
  • 

    Thanks Karen,                                                                                                                               I'm not using VS at all. My code is ready  in 2005 .NET version of Express Edition, which I downloaded from an Internet -I got quite complex queries for old legacy scientific data converted to DataTable, but that's all I can do.  Everything works perfect.  All I  need (desperatly) are more advanced features of LINQ to be  implemented.                                                                                                                                        What would be the fastest and less complicated way of getting in this situation into 2008 version, but (I repeat not VS) only  VBasic is taken into consideration    Best Regards, Andrzej                                                                                                                                                                 

    Monday, November 13, 2017 6:51 PM
  • 

    Thanks Karen,                                                                                                                               I'm not using VS at all. My code is ready  in 2005 .NET version of Express Edition, which I downloaded from an Internet -I got quite complex queries for old legacy scientific data converted to DataTable, but that's all I can do.  Everything works perfect.  All I  need (desperatly) are more advanced features of LINQ to be  implemented.                                                                                                                                        What would be the fastest and less complicated way of getting in this situation into 2008 version, but (I repeat not VS) only  VBasic is taken into consideration    Best Regards, Andrzej                                                                                                                                                                 

    Yes you are using Visual Studio. When you indicate "2005 .NET version of Express Edition" That is VS2005 Express Edition.

    EDIT: Hopefully this makes sense. Wish I could give you something to make this work but the bottom line is you need Framework 3.5 which VS2005 does not support. If you were say in VS2017 you could work backwards but that is not the case here, you can move forward as VS2005 (or as you refer to it as 2005 .NET version of Express Edition) can work with .NET Framework 3.5. Same goes for C# which is why a developer created LinqBridge which gives most of LINQ in VS2005 under .NET Framework 3.0.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Monday, November 13, 2017 7:02 PM
    Moderator
  • There should be not any problem if you use Visual Studio 2017 Community edition. (Freeware to use with limitations if it is real big business).

    If you use then .Net 4.6 or .4.7 you probably have not any problem. (4.0 has some problems with .Net 3.5 code).

    https://www.visualstudio.com/downloads/


    Success
    Cor

    Monday, November 13, 2017 11:50 PM
  • Yeah, that's actually what I did before started asking for your help on community forum.  1GB od size is the latest 2017 monster and then I notices I can't  even navigate  through it while the code is ready to implement with LINQ. Eventually I found a place to load 2008 Express version (with 30 days limit), but hope to finish by that time my assignment.  VB.NET 2008  is almost exactly the same as 2005, so I don't need to learn a new IDE.  So far I'm very happy, it's really fast and takes only 150 MBytes of space.      PS: I like your previous remark "I love VB", not mentioning a fact that by beginning of '90, I worked briefly with DOS version of VB before  'introducing' 1'st Windows revolutionary version of VB3 to the industrial environment, where I was working by the time. Thanks a milion. Andrzej                                                                                                                                                                                                                                  

    
    Tuesday, November 14, 2017 1:40 PM
  • In mine opinion 2012 was the best, the latest of the non open software. 

    So if you can find that one, then get it. 


    Success
    Cor

    Tuesday, November 14, 2017 2:06 PM
  • Thanks Karen for your answer!  Once I'm here I got another LINQ related question, which as I can see hundreds of times were posted on the WEB but not clear and smart solution in VB.NET was ever given.  Famous Error 9 'CopyToDataTable' is not a member of 'System.Collections.Generic.IEnumerable(Of <anonymous type>)' prevents from doing  anything like   <table = query.CopyToDataTable>  or  similar. I got my answers from  my code after LINQ query, which I found as a string  in the following format:   row(i) = "{  field1 = val1, field2 = val2, ...., fieldn = valn }", so I can do eventually some split to get the values out of it and create a new datatable, but I want to avoid  excesive looping  in <For Each row In query>  as I'm dealing with many records of scientific data.   Did you ever come across any clever and simple solution of dumping contents of LINQ query directly  into datatable?   Thanks in advance of pointing me in the right direction. Regards, Andrzej 

    
    Tuesday, November 14, 2017 5:30 PM
  • I never had to take a Entity Framework result to a DataTable. Instead back when developing Windows apps I would query data in a database via SqlClient data provider into a DataTable or DataSet then run Lambda (the method based way to LINQ) where results would output to a List(Of T). In rare cases I would use a language extension method to create a DataTable which used generics to create the DataTable (sounds like you may have come across this already).

    Bottom line is no matter what you have seen the solution will always involve (at least from my viewpoint) iteration of columns and rows.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, November 14, 2017 6:30 PM
    Moderator
  • The datatable is a very special collection. It is a part of the DataSet. It was created in .Net 1.0 as the first container for not connected server usage. 

    Some thought it is huge. It is not, but it has endless references. You cannot set simple an anonymous collection to that the same as ToList (which is in fact an ArrayList with generic properties added). 

    Therefore there is no simple solution to set an Anonymous collection, which has named properties, to a datatable. 

    A datatable has its names in the parent dataset columns description.  


    Success
    Cor


    • Edited by Cor Ligthert Tuesday, November 14, 2017 11:01 PM changed connection to references, brain fart
    Tuesday, November 14, 2017 7:35 PM
  • Thanks Karen for your answer!  Once I'm here I got another LINQ related question, which as I can see hundreds of times were posted on the WEB but not clear and smart solution in VB.NET was ever given.  Famous Error 9 'CopyToDataTable' is not a member of 'System.Collections.Generic.IEnumerable(Of <anonymous type>)' prevents from doing  anything like   <table = query.CopyToDataTable>  or  similar. I got my answers from  my code after LINQ query, which I found as a string  in the following format:   row(i) = "{  field1 = val1, field2 = val2, ...., fieldn = valn }", so I can do eventually some split to get the values out of it and create a new datatable, but I want to avoid  excesive looping  in <For Each row In query>  as I'm dealing with many records of scientific data.   Did you ever come across any clever and simple solution of dumping contents of LINQ query directly  into datatable?   Thanks in advance of pointing me in the right direction. Regards, Andrzej 

    

    You like that Ford Model T, huh?

    Maybe, you should step to the Mustang. :)

    https://dzone.com/articles/reasons-move-datatables

    http://lauteikkehn.blogspot.com/2012/03/datatable-vs-list.html

    Tuesday, November 14, 2017 8:19 PM
  • Hej Cor,

    Thanks a million for your comments. Slowly but surely progressing with my project ...The more I use LINQ, the more I like it. Actually once you have your data source in form of DataTable, the scheme of doing things is simple:

            Dim _Table As DataTable =  ...interface to legacy data...

            ' Query _Table for an Integer Field called "Name" = value
            Dim query = From x In _Table.AsEnumerable() Where x.Field(Of Integer)("Name") = value Select x

            ' Create a new table from the query.
            Dim nTable As DataTable = query.CopyToDataTable()

    Tuesday, November 14, 2017 10:18 PM
  • You can learn a good deal from the following link about LINQ.

    Also, we can play (note the indexing in Sub Indexing)

    https://dotnetfiddle.net/gKnaFY


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, November 15, 2017 12:49 AM
    Moderator
  • The benchmark "DataTable vs List" is misleading and in overall has no value, at all, as relates just to creation process od  DataTable and List. Real test should take in consideration complex transactions, not just one off IO process. I'm dealing with monotonous statistical, mostly integers and double, type of data and so far I'm surprised how well simple VB.NET code performs.  If I have time perhaps do some benchmarks, so when they ready will try to publish...
    Wednesday, November 15, 2017 12:10 PM
  • Thanks Karen for the example from https://dotnetfiddle.net .Obviously having VB.NET 2008  I can't fully compile your program (which needs Roslyn  Platform), but I managed few  changes, which was an additional benefit for me  to analize and  better understand your code.    I don't need such sophisticated   coding, but it is great working example to play and learn from. Now  I'm getting addicted to LINQ and latest VB...It's a big fun. Best Regards.  Andrzej 
    Thursday, November 16, 2017 8:26 AM
  • Hi AteDe,

    If Kareninstructor's  post resolve your issue, please remember to close your thread by marking her post as answer, it is beneficial to other community members who face the same issue.

    Thanks for your understanding.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 20, 2017 8:44 AM
    Moderator
  • The benchmark "DataTable vs List" is misleading and in overall has no value, at all, as relates just to creation process od  DataTable and List. Real test should take in consideration complex transactions, not just one off IO process. I'm dealing with monotonous statistical, mostly integers and double, type of data and so far I'm surprised how well simple VB.NET code performs.  If I have time perhaps do some benchmarks, so when they ready will try to publish...

    yeah, you prove otherwise, because you saying something has no value. You know this, right?
    Monday, November 20, 2017 10:05 AM
  • I am going to say one other thing about this and the link provided about datatable vs list. A poster came into the C# forum one day talking about he was processing data using a datatable that kept blowing up due to the amount of data that was being processed as it kept blowing up as the datatable sucked up the memory.

    I finally convinced the poster t go to a collection, a list, the uses 6 times less memory, the link was provided to the poster about datatable vs list, and he switched from DT to list that allowed the process to complete.

    The link has no value due to ignorance has  value to others that have seen the link I posted and know the value of the link.  

    https://chrisbitting.com/2016/05/04/datatable-row-loop-csharp-performance-testing-linq-vs-select-vs-parallel-vs-for/

    On one hand you're trying to use Linq, and on the other hand, you are trying to use Linq with a datatable. It is kind of horrific.  That you are doing some kind of statistical analysis using the Ford Model T with the process running longer than it should be is due to not knowing any better.

    Monday, November 20, 2017 10:48 AM
  • The datatable is a very special collection. It is a part of the DataSet. It was created in .Net 1.0 as the first container for not connected server usage. 

    Some thought it is huge. It is not, but it has endless references. You cannot set simple an anonymous collection to that the same as ToList (which is in fact an ArrayList with generic properties added). 

    Therefore there is no simple solution to set an Anonymous collection, which has named properties, to a datatable. 

    A datatable has its names in the parent dataset columns description.  



    I noticed that already, that's why using DataTable is more straightforward and easy to implement, while List might be faster  (as it says DA924x) but   is huge and endless,  which makes R&D at the end of day   much more difficult and longer!  Once I define and set up my columns on the fly, while reading the legacy data:

      Dim dTable As New DataTable("_newData"

            table.Columns.Add("Field1", GetType(Integer))
            table.Columns.Add("Field2", GetType(String))
            table.Columns.Add("Field3", GetType(Double))
            etc.....

    it goes forever, while I'm strugling with List equivalent of above: 

        Public Structure MyTypeOfT

            Private Field1 As Integer
            Private Field2 As String
            Private Field3 As Double
        etc.....

            Public Sub New(ByVal _x As Integer, ByVal _y As String, ByVal _z As Double)
                Field1 = _x
                Field2 = _y
                Field3 = _z

                ........

            End Sub

        End Structure

       and 

       Dim _newData As New List(Of MyTypeOfT)

    (to  be continued)




    • Edited by ATeDe Thursday, November 30, 2017 1:22 PM Mistake
    Wednesday, November 29, 2017 11:51 AM
  • Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

          Once is done, will click "Mark as Answer"
    Wednesday, November 29, 2017 11:54 AM