Solved

LINQ Query problem

Posted on 2014-02-26
5
375 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
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

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

Author Comment

by:5281
Comment Utility
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 450 total points
Comment Utility
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 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 50 total points
Comment Utility
Are you getting an exception at run time?
0
 

Author Comment

by:5281
Comment Utility
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

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

Title # Comments Views Activity
Object to array 7 26
Wpf develop 5 29
Tabcontrol Caption? 1 21
VB.NET HttpWebRequest 12 30
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

10 Experts available now in Live!

Get 1:1 Help Now