开发者

LINQ Query to match a sequence

开发者 https://www.devze.com 2023-01-14 15:17 出处:网络
I have aresult set, say clientList. And I want to make sure that ALL the clients in the ClientList have a P开发者_运维问答rofession as \"Banker\". Let the result of the query be a boolean value.

I have a result set, say clientList. And I want to make sure that ALL the clients in the ClientList have a P开发者_运维问答rofession 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?


 if ( clientList.All(c=>c.Profession=="Banker") )
 {
  }


 bool allAreBankers = ClientList.All(c=>c.Profession=="Banker");
0

精彩评论

暂无评论...
验证码 换一张
取 消