Skip to content

Projection

Context: Projection operators (Select, SelectMany) transform each element into a new form.

var numbers = new[] { 1, 2, 3 };
var squares = numbers.Select(n => n * n); // 1,4,9
// SelectMany flattens collections
var lists = new[] { new[] { 1, 2 }, new[] { 3, 4 } };
var flat = lists.SelectMany(l => l); // 1,2,3,4

DTO projection: Use Select to map domain entities to view models or DTOs.

Example: In EF Core, Select is used to load only needed columns.