I'm starting to use the LinqKit PredicateBuilder to create a predicate with OR conditions that are not possible with Linq expressions.
The problem I am facing is if I start with PredicateBuilder.True<MyEntity>() , it returns all the rows , and if I start with PredicateBuilder.False<MyEntity>() , then it returns no rows , except what expressions do I I use it! 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 rows with IsActive == true, but it returns all rows!
I tried all possible combinations of PredicateBuilder.True | PredicateBuilder.False with And | Or methods, but they do not work!
Ashkan
source share