An expression tree is a structured representation of a LINQ query. IQueryable<T> builds this representation from query operators, allowing a provider such as EF Core to translate it into a database query. section 5.1.3 section 5.7
A query remains an expression tree until its results are consumed:
- Start with an IQueryable<T> source such as _context.BoardGames. section 5.1.3
- Add LINQ operators such as Where and OrderBy; chained or separate calls produce the same query representation. section 5.1.3
- Execute the query with an operator such as ToArray(), causing EF Core to fetch records and create the result. section 5.2
Filtering board games
var query = _context.BoardGames.Where(b => b.Year == 2020);\nvar bgArray = query.ToArray();\n\nThe first line builds the expression tree without querying the database. The second line consumes the results, so the provider translates and executes the query. section 5.1.3 section 5.2
var query = _context.BoardGames .Where(b => b.Year == 2020) .OrderBy(b => b.Name);
Inspect a complete expression-tree construction using filtering and ordering. section 5.1.3

