Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LINQ Where and
Message
De
22/11/2012 13:17:05
 
 
À
22/11/2012 13:01:52
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Titre:
Divers
Thread ID:
01557814
Message ID:
01557824
Vues:
45
>>I have this LINQ statement which is not functioning as I expect:
>
>Not looked closely but how is it functioning? :-}

Once I pass any value in in either of the parameters I get all records coming out.

>
>>
>>
            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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform