views:

22

answers:

2

Hi, I have a result set, say clientList. And I want to make sure that ALL the clients in the ClientList have a Profession as "Banker". Let the result of the query be a boolean value.

How can I write the LINQ or lambda expression query to get the result?

+2  A: 
 if ( clientList.All(c=>c.Profession=="Banker") )
 {
  }
James Curran
alternatively use c.Profession.Equals("Banker")... same difference though.
BenAlabaster
+1  A: 
 bool allAreBankers = ClientList.All(c=>c.Profession=="Banker");
p.campbell