Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LINQ Query problem

Posted on 2014-02-26
5
Medium Priority
?
383 Views
Last Modified: 2016-02-10
I have a LINK Query, it is suppose to select a record, but it just doesn't select anything out.  What's wrong with my query?

Dim query As List(Of Class1) = (From c In customers _
 Where c.customerID = "100" AndAlso c.StoreNumber = "B100" AndAlso c.State = "GA" _
                                                         Select c).ToList()

I want the customer whose customerID is 100, and storenumber is B100 and state is Georgia to be selected, but nothing come out.
0
Comment
Question by:5281
[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
  • 2
5 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 39890010
Is customerID a numeric or a string?  If numeric, try  c.customerID = 100
0
 

Author Comment

by:5281
ID: 39890024
customerID is a string.  If I just select customerID like below, it would work, if I added other criteria, it doesn't select anything out.

Dim query As List(Of Class1) = (From c In customers _
                                                     Where c.customerID = "100" _
                                                         Select c).ToList()
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 1800 total points
ID: 39890031
Have you tried each of the other 2 criteria (store number and state) separately to see if one of them cancels everything out?
0
 
LVL 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 200 total points
ID: 39890085
Are you getting an exception at run time?
0
 

Author Comment

by:5281
ID: 39890200
Oh, yes.  When I tried seperately, one of criterial storenumber cancel out everything.  I found I did not use Trim() function when I read them into List.  So it may contain space.  Thank you for your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 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