How to combine (OR) two expression trees

c# expression-trees

Question

I have two type: expression trees.Expression<Func<string, bool>> and I want to find a single phrase that will combine the two expressions into one (passing the same string parameter to both expressions) Any ideas?

1
1
7/11/2013 3:16:16 PM

Popular Answer

Use PredicateBuilder using LINQKit to do this. For instance:

Expression<Func<string, bool>> e1 = …;
Expression<Func<string, bool>> e2 = …;
Expression<Func<string, bool>> combined = e1.Or(e2).Expand();
4
7/11/2013 7:09:50 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow