views:

270

answers:

4

I have recently written a dynamic querying tool using expression trees and as I went the power of expression trees began to dawn on me. My querying tool could also form the basis of a reporting tool, a dynamic decision engine and maybe other cases where you need to work with dynamic objects in abstract ways.

The process has been painful (recursive calls to generic methods by reflection - ugh) so I am wondering whether anyone has created a generic library that might harness the power of expression trees to accomplish some of these kinds of tasks? I have seen PredicateBuilder but does anyone know of any others?

A: 

Have you looked at LINQ and the IQueryable interface? That's how they implemented LINQ to SQL, etc.

Travis
+2  A: 

Generic operators (in MiscUtil) is a pretty well utilised bit of code based on expression trees; very simple, but very versatile. Some other ideas:

(lots of others)

Marc Gravell
+1  A: 

Have you looked at the DLR? I don't know much about it in detail, but my understanding is that the expression-tree mechanism which is behind the scenes in Linq-to-SQL has effectively been published in the DLR.

Will Dean
No, this is not true. It looks similar, but the DLR is by far inferior.
leppie
DLR trees share a lot of common ground with Expression, and IIRC they are a bit more merged in .NET 4.0 CTP.
Marc Gravell
+2  A: 

Check out LINQExtender

Mauricio Scheffer