Skip to content

Condition

Artem Kirgizov edited this page May 31, 2021 · 4 revisions
Namespace: Toolkit

Condition - allows you to build a chain of logical conditions. It can be useful in a large number of conditions, for example, when querying data using EntityFramework. The object of the Condition class is implicitly cast to the bool type.

The main features of the class:

int a = 20;
var result = Condition.Check(a == 10); // will be false
int a = 10;
int b = 20;
var result = Condition
            .Check(a == 10)
            .And(b == 20); // will be true
int a = 10;
int b = 20;
var result = Condition
            .Check(a == 10)
            .AndNot(b == 20); // will be false
int a = 10;
int b = 20;
var result = Condition
            .Check(a == 10)
            .And(b == 20);
            .Or(b == 5) // will be true
int a = 10;
int b = 20;
var result = Condition
            .Check(a == 10)
            .And(b == 20);
            .Or(b == 5)
            .Not() // now it's false
  • And others
Clone this wiki locally