Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
LINQ Where and
Message
From
22/11/2012 09:08:29
 
 
To
All
General information
Forum:
ASP.NET
Category:
LINQ
Title:
LINQ Where and
Miscellaneous
Thread ID:
01557814
Message ID:
01557814
Views:
82
Hi,

I have this LINQ statement which is not functioning as I expect:
            IQueryable<CustomerEntity> query = from customer in this.ObjectContext.CustomerEntitySet
                                               where ((customerNumber != string.Empty ? customer.cus_number.Contains(customerNumber) : true)
                                                  && (customerLastName != string.Empty ? customer.cus_lastname.Contains(customerLastName) : true))
                                               select customer;
The logic I am trying to get is:

Get all records where the customerNumber and customerLastName match.

so If I have Cazabon, 0001 and Charles, 0002 as my records (Last Name, Number) and the user searches for z, 2, I should get no records back. If the y search for z, 1 then Cazabon, 0001 should return. If they search for just c, then both records should return.

What is the correct way to do this?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform