简体   繁体   English

如何编写LINQ查询来检查多个条件?

[英]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. 我还想添加b.PartitionKey不等于我存储在变量pk等变量中的值的检查。 Is there a way that I can add this into the b => ?? 有没有一种方法可以将其添加到b => ??中?

这个怎么样?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在LINQ查询中包括多个层次? - How can I include more than one level deep in a LINQ query? 如何在LINQ表达式中订购多个级别? - How can I order at more than one level in a LINQ expression? 我怎么能。在LINQ中包含多个级别? - How can I .Include down more than one level in LINQ? 如何使用LINQ简化(加速)从包含超过一百万条记录的数据库中选择查询 - How can I simplify (speed up) the selecting query from a database that contains more than 1 million records using LINQ LINQ 使用 OR 选择多个条件 - LINQ select with more than one condition using OR 如何检查两个以上的值<condition> ?<if true> :<if false> ? - How can I check more than two values with <condition>?<if true>:<if false>? 动态Linq查询以动态方式联接两个以上具有条件的表 - Dynamic Linq query for join two tables with more than one condition(dynamically) 如何使用LINQ为包含多行LIST的条目选择? - How can I select using LINQ for an entry that contains a LIST with more than one row? 如何使用LINQ检索列表中包含一个列表的多个属性的条目? - How can I use LINQ to retrieve entries that contain more than one property of a list within a list? 如何在LINQ表达式中包含多个层次? - How can I include down more than one level in a LINQ expression?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM