I'm beginning to use LinqKit's PredicateBuilder to create predicate's with OR conditions which is not possible with Linq expressions.
The problem I'm facing is if I begin with PredicateBuilder.True<MyEntity>()
it returns all rows and if I begin with PredicateBuilder.False<MyEntity>()
it returns non rows, apart from what expressions I use! look at the code below:
var pre = PredicateBuilder.True<MyEntity>();
pre.And(m => m.IsActive == true);
using (var db = new TestEntities())
{
var list = db.MyEntity.AsExpandable().Where(pre).ToList();
dataGridView1.DataSource = list;
}
It should return the rows which has IsActive == true, but it returns all rows!
I have tried all the possible combinations of PredicateBuilder.True
| PredicateBuilder.False
with And
| Or
methods, non of them works!