LINQ Query Syntax in C#
From the C# Programming Language cheat sheet · LINQ and Lambda Expressions · verified Jul 2026
LINQ Query Syntax
Querying collections with LINQ
csharp
// Query syntax
var adults = from p in people
where p.Age >= 18
select p;
// Method syntax
var adults2 = people.Where(p => p.Age >= 18);
// Common operations
var names = people.Select(p => p.Name);
var sorted = people.OrderBy(p => p.Age);
var first = people.First();💡 LINQ provides SQL-like querying for .NET collections
⚡ Method syntax often more flexible than query syntax
📌 Lambda expressions (=>) create anonymous functions
🟢 LINQ is lazy-evaluated until enumerated