What is the best way to do a conditional query using linq to objects(not linq to sql).
Currently I am using the Predicate builder found here http://www.albahari.com/
Just change PredicateBuilder
to use delegates instead of expression trees and use lambdas to build the results:
public static class DelegatePredicateBuilder
{
public static Func True() { return f => true; }
public static Func False() { return f => false; }
public static Func Or(this Func expr1,
Func expr2)
{
return t => expr1(t) || expr2(t);
}
public static Func And(this Func expr1,
Func expr2)
{
return t => expr1(t) && expr2(t);
}
}