If you do not get the benefits of expression trees, I think:
- either you do not have code that requires expression trees
- or you donβt see a place where your code can be improved using expression trees.
The first point is fine. Most of the applications I developed did not have a place for expression trees. And to deal with the second point, you just need to know what expression trees are, how they work and what they can / cannot do.
Expression trees are commonly used when you need to be able to cross some code model, for example, to create different code based on this. As already mentioned, this approach is used, for example, in Linq-to-SQL. Another example, not from the boxes, can be an application in which you need to have an object property as an object of a first class class in your application, that is, you must be able to pass the property as an instance of some class. The same can be done with reflection, but expression trees allow you to make the code less restrictive.
source share