SolvedPrivate

LINQ Query exclude records in select

Posted on 2014-02-27
2
37 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 62

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

19 Experts available now in Live!

Get 1:1 Help Now