SolvedPrivate

VB Linq to straight VB

Posted on 2014-02-28
4
44 Views
Last Modified: 2016-02-10
Stupid question of the day...

How can I make the following linq statement into a straight vb statement

I'd like the results to be a datatable

            Dim Query = _
            (From Region In dataset1.Tables(0) _
             Where Region.Field(Of String)("Region") <> "" _
                    Select Region.Field(Of String)("Region") _
             ).Distinct().OrderBy(Function(item) item).ToList

Open in new window

0
Comment
Question by:lrbrister
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39894758
Do you want to convert it to ADO.NET code to populate datatable or do you want to convert the result of this LINQ query into a datatable?

It is currently giving you a list of string which you can loop through.
0
 

Author Comment

by:lrbrister
ID: 39894768
CodeCruiser

The end goal is something that a rabid "anti-linq" person could use.

You've been answering my questions for quite some time...I don't care one way or the other personally.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39894944
From your "anti-linq" usage, I am assuming you want to get rid of the query.

If I remember correctly, you know how to use a tableadapter to populate a datatable so its a matter of constructing a sql query like below

SELECT DISTINCT Region From Regions Where Region Is Not Null And Len(Region) > 0 Order By Region
0
 

Author Closing Comment

by:lrbrister
ID: 39894972
Thanks.

I wrote the linq query with some EE help.

The other team members hate linq for some reason and want it out.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

809 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