Thursday, February 15, 2018

PredicateBuilder.True vs PredicateBuilder.False

Getting Started With The Predicate Builder

With the PredicateBuilder, we'll be using ANDs and OR to combine smaller LINQ queries into a single expression.
Each predicate is created with a default bool value used anchor our expression. The easiest way to think of this:
  • Use true with ANDs
  • Use false with ORs
Anchoring an AND to a false will never allow an expression to evaluate because false && {any expression} is false. Anchoring an OR to a true will always force an expression to evaluate because true || {any expression} is true. Make sense? If not, don't worry. Just follow 2 rules above and you'll be good.

No comments:

Post a Comment