简体   繁体   中英

How can I code up a LINQ query to check for more than one condition?

I have the following:

   var pk = "001";
   if (accounts.Any(b => b.Title.Equals(account.Title)))

What I would like to do is to also add a check that b.PartitionKey is not equal to a value I stored in a variable such as the variable pk. Is there a way that I can add this into the b => ??

这个怎么样?

if (accounts.Any(b => b.Title.Equals(account.Title) && !b.PartitionKey.Equals(pk)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM