LINQ (Language Integrated Query) tillhandahåller ett enhetligt, expressivt sätt att fråga och transformera data — samlingar, databaser, XML — med en konsistent syntax. Det för funktionell-stil operationer (filter, map, group, aggregate) direkt in i C#, vilket gör datamanipulation koncis och läsbar.
Method syntax (den vanliga formen)
adults = people
.Where(p => p.Age >= )
.OrderBy(p => p.Name)
.Select(p => p.Name.ToUpper())
.ToList();
total = numbers.Sum();
count = people.Count(p => p.IsActive);
first = people.FirstOrDefault(p => p.Id == );
any = people.Any(p => p.Age > );
groups = people.GroupBy(p => p.City);
max = people.Max(p => p.Age);
