0

I'm developing a small filtering based on the 3 fields. I'm also using the MySQL Connector in my MVC 3 project.

I've found a nice looking PredicateBuilder http://www.albahari.com/nutshell/predicatebuilder.aspx . but it seems not to be working with the MySQL

 var predicate = PredicateBuilder.False<Order>();

  if(OrderID == 0)
      predicate = predicate.And(x => x.OrderID == 9); //an example, that order exist in the DB

  var result = (from x in db.Order select x).AsExpandable()
               .Where(predicate).ToList();

but the result contains 0 elements. Why ?

Tony
  • 12,405
  • 36
  • 126
  • 226

1 Answers1

1

Because you started with false and are using AND you will always get false. Start with True instead:

var predicate = PredicateBuilder.True<Order>();
Daniel Baker
  • 241
  • 1
  • 4