projection
Choosing which fields or columns a query returns, or reshaping each result into a different form.
In more detail
In SQL the select list performs projection, while the WHERE clause performs selection, which chooses rows. In LINQ and other collection libraries a Select or map operation projects each item. Projecting to just the fields you need keeps queries and responses small.
Example
.Select(p => new ProductResponse(p.Id, p.Name, p.Price))Related terms
- LINQ — Language Integrated Query: a set of C# operators such as Where, Select and OrderBy for filtering, shaping and combining sequences of data.
- Entity Framework Core — Microsoft's object-relational mapper for .NET, which lets code query and save database data as C# objects and translates LINQ into SQL.
- DTO — A plain object whose only job is to carry data across a boundary, such as the body of an API request or response.
- SELECT — The SQL statement that reads data: it names the columns you want in the answer and, with FROM, the tables they come from.
- WHERE clause — The part of a query that keeps only the rows for which a condition is true.
- column — A named, typed field that every row of a database table has, such as name or price.
Taught in
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Querying, Change Tracking, and Saving Data — Modern .NET Core, C# & Enterprise Microservices
- The SELECT Statement And Projection — PostgreSQL, Indexing & Relational Data Modeling