Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LINQ Where and
Message
De
22/11/2012 09:08:29
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Titre:
LINQ Where and
Divers
Thread ID:
01557814
Message ID:
01557814
Vues:
81
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform