SolvedPrivate

LINQ Query exclude records in select

Posted on 2014-02-27
2
40 Views
Last Modified: 2016-02-10
My LINQ Query below works fine

However...

There are about 500 empty or zero length records being inserted into the results set.

How do I exclude those records in the select?

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

Open in new window

0
Comment
Question by:lrbrister
2 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39893305
Try it like this.

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

Open in new window

0
 

Author Closing Comment

by:lrbrister
ID: 39894618
Put me on the right track.

The final solution was actually this one...
There WAS data there...but it was = ""
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 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