Est. 2007 Intermediate

LINQ

A declarative query syntax integrated into .NET languages that brings SQL-like, strongly typed data querying to C#, Visual Basic, and beyond.

Created by Anders Hejlsberg, Erik Meijer, and the Microsoft C# team

Paradigm Declarative: Query, Functional
Typing Static, Strong, Type-inferred
First Appeared 2007
Latest Version Bundled with .NET (latest .NET 10, 2025)

Overview

LINQ (Language Integrated Query) is a component of the Microsoft .NET platform that adds native, strongly typed data querying capabilities to .NET languages such as C# and Visual Basic. Rather than being a standalone programming language, LINQ extends its host languages with query expressions and a uniform set of standard query operators that work the same way across diverse data sources—in-memory collections, relational databases, XML documents, and more.

LINQ addresses a long-standing mismatch between general-purpose programming languages and the data they consume. Before LINQ, querying a database, an XML document, and an in-memory list each required different APIs, and queries were often embedded as strings the compiler could not check. LINQ unifies these into a declarative model where queries are first-class language constructs subject to compile-time type checking and full IDE support, including autocomplete.

History & Origins

LINQ grew out of Microsoft’s effort to close the gap between programming languages and data—an area heavily shaped by the work of Erik Meijer and the research language Cω, which experimented with integrating relational and XML data access directly into a C-like language. Anders Hejlsberg, the lead architect of C#, drove the language design work that turned these ideas into a shipping feature.

Microsoft previewed LINQ publicly at its Professional Developers Conference in September 2005, presenting it as a coordinated set of language and library changes for C# and Visual Basic. Over the following two years the design was refined alongside the supporting language features it required, including lambda expressions, extension methods, anonymous types, type inference, and expression trees.

LINQ shipped as a major part of .NET Framework 3.5 on November 19, 2007, together with C# 3.0, Visual Basic 9.0, and Visual Studio 2008. The release included several providers out of the box: LINQ to Objects for in-memory collections, LINQ to XML for XML documents, and LINQ to SQL for SQL Server databases.

Design Philosophy

LINQ is declarative in style: a query expresses what data is wanted rather than how to iterate over it. Its design rests on a small number of core ideas:

  • Uniformity — a single query syntax and operator set spans many data sources through a provider model.
  • Type safety — queries are checked at compile time against the host language’s type system, with type inference filling in element and result types.
  • Composability — deferred (lazy) execution lets queries be built up and combined before any data is materialized.
  • Functional foundations — the operator set draws on functional programming and comprehension-style querying; SelectMany, for example, corresponds to the monadic bind operation.

Key Features

  • Two syntaxes — queries can be written in query expression syntax (from, where, select, group, orderby) or in method syntax using chained calls to the standard query operators. The compiler translates query syntax into method calls.
  • Deferred execution — many operators are lazy; a query describing a computation is not run until its results are enumerated, enabling efficient pipelines.
  • Provider modelIEnumerable<T> backs in-memory data, while IQueryable<T> and expression trees let providers translate queries into other forms, such as SQL.
  • Standard query operators — a rich library of operators including Where, Select, OrderBy, GroupBy, Join, Aggregate, and many more.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Linq;
using System.Collections.Generic;

var people = new List<(string Name, int Age, string City)>
{
    ("Ada", 36, "London"),
    ("Grace", 41, "New York"),
    ("Alan", 29, "London"),
    ("Edsger", 52, "Austin"),
};

// Query syntax: select Londoners' names, ordered by age
var londoners =
    from p in people
    where p.City == "London"
    orderby p.Age
    select p.Name;

foreach (var name in londoners)
    Console.WriteLine(name);

// Equivalent method syntax
var averageAge = people
    .Where(p => p.City == "London")
    .Average(p => p.Age);

Console.WriteLine($"Average London age: {averageAge}");

Evolution

In the years after its release, LINQ continued to evolve through the broader .NET ecosystem. LINQ to Entities arrived with the Entity Framework in .NET Framework 3.5 SP1 (2008), parallelized execution was added through PLINQ in .NET Framework 4.0 (2010), and the standard query operators became a fixture of idiomatic .NET code. When .NET moved to an open-source, cross-platform model with .NET Core in 2016, LINQ carried over as a core part of the base class library, and it remains bundled with current .NET releases.

Current Relevance

LINQ is an actively maintained, core part of the .NET base class library and is ubiquitous in modern C# and Visual Basic code. It underpins data access through Entity Framework Core, drives in-memory transformations across virtually every kind of .NET application, and continues to benefit from performance and language improvements that ship with each .NET release.

Why It Matters

LINQ popularized the idea of integrating declarative, type-checked queries directly into a mainstream general-purpose language. Its query expression model and standard query operators became a defining feature of idiomatic C# and Visual Basic, and the supporting language features it required—lambda expressions, extension methods, type inference, and expression trees—reshaped how .NET code is written well beyond querying. Its approach also influenced other parts of the ecosystem, including F# 3.0’s query expressions, and helped make fluent, composable query and transformation pipelines a familiar pattern across modern programming.

Timeline

2005
LINQ previewed publicly at Microsoft's Professional Developers Conference (PDC)
2007
LINQ released as part of .NET Framework 3.5 with C# 3.0, Visual Basic 9.0, and Visual Studio 2008
2008
LINQ to Entities ships with the Entity Framework in .NET Framework 3.5 SP1
2010
Parallel LINQ (PLINQ) introduced in .NET Framework 4.0 for parallelized query execution
2012
F# 3.0 introduces query expressions modeled on LINQ
2016
LINQ ships cross-platform as part of the base class library in .NET Core 1.0

Notable Uses & Legacy

Entity Framework

Microsoft's ORM uses LINQ as its primary query interface, translating LINQ to Entities queries into SQL

LINQ to Objects

Querying and transforming in-memory collections such as arrays and List<T> across countless .NET applications

LINQ to XML

Constructing, querying, and transforming XML documents with strongly typed query syntax

PLINQ

Parallelizing data-processing queries across multiple cores via the standard query operators

Language Influence

Influenced By

SQL Haskell

Influenced

Running Today

Run examples using the official Docker image:

docker pull
Last updated: