256 Contributors: 9 Tuesday, November 29, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial:
Roadmap: roadmap

Expression Trees


Expression trees are data structures used to represent code expressions in the .NET Framework. They can be generated by code and traversed programmatically to translate the code to another language or execute it. The most popular generator of Expression Trees is the C# compiler itself. The C# compiler can generate expression trees if a lambda expression is assigned to a variable of type Expression<Func<...>>. Usually this happens in the context of LINQ. The most popular consumer is Entity Framework's LINQ provider. It consumes the expression trees given to Entity Framework and generates equivalent SQL code which is then executed against the database.

Related Examples