I have a line of code using where:
codebase.Methods.Where(x => x.Body.Scopes.Count > 5);
How can I insert more than one condition? So I can say x => predicate && y => predicate
?
Thanks
Well, you can just put multiple "where" clauses in directly, but I don't think you want to. Multiple "where" clauses ends up with a more restrictive filter - I think you want a less restrictive one.
You can specify multiple conditions in a single WHERE clause to, say, retrieve rows based on the values in multiple columns. You can use the AND and OR operators to combine two or more conditions into a compound condition. AND, OR, and a third operator, NOT, are logical operators.
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"));
Or you can use a separate Where
call for each condition:
codebase.Methods.Where(x => x.Body.Scopes.Count > 5) .Where(x => x.Foo == "test");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With