Expression Trees in LINQ
In LINQ, expression trees are used to represent structured queries that target sources of data that implement IQueryable<T>. For example, the LINQ to SQL provider implements the IQueryable<T> interface for querying relational data stores. The C# and Visual Basic compilers compile queries that target such data sources into code that builds an expression tree at runtime. The query provider can then traverse the expression tree data structure and translate it into a query language appropriate for the data source.
Expression trees are also used in LINQ to represent lambda expressions that are assigned to variables of type Expression<TDelegate>.
Expression trees can also be used to create dynamic LINQ queries. For more information, see How to: Use Expression Trees to Build Dynamic Queries. You might also use expression trees if you are building a LINQ provider. For more information, see Walkthrough: Creating an IQueryable LINQ Provider.