在LINQ的方法在哪里使用多个条件 [英] Using more than one condition in linq's where method
本文介绍了在LINQ的方法在哪里使用多个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的代码行:
codebase.Methods.Where(x => x.Body.Scopes.Count > 5);
我如何可以插入多个条件吗?所以我可以说 X =>谓语和放大器;&安培; Y =>谓词
?
感谢
推荐答案
你可以滚你的独立条件到一个单一的谓词,如果你喜欢:
You can roll your separate conditions into a single predicate if you like:
codebase.Methods.Where(x => (x.Body.Scopes.Count > 5) && (x.Foo == "test"));
或者你可以使用一个单独的其中,
通话每个条件:
codebase.Methods.Where(x => x.Body.Scopes.Count > 5)
.Where(x => x.Foo == "test");
这篇关于在LINQ的方法在哪里使用多个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文