Solved

LINQ Query problem

Posted on 2014-02-26
5
381 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 450 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 63

Assisted Solution

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSIS Column mapping 5 40
SSIS - Using VB.NET to parse XML file 11 41
vb.net code 9 28
Trying to check to see if email is in valid format in asp.net 3 22
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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