?
SolvedPrivate

LINQ Query exclude records in select

Posted on 2014-02-27
2
Medium Priority
?
44 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 2000 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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

777 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