We have covered a lot of history in this series so far. We have covered many incremental improvements to C# and .NET. Things such as Auto-Implemented Properties were improvements, but they felt like incremental improvements to the language (although I think that one notable exception would be the addition of Lambda expressions).

LINQ wasn’t a small change to the C# language. LINQ, which stands for Language Integrated Query, really changed how we can write code in C#.

LINQ can be seen as a way to structure queries in a more SQL-like syntax. Which, if you come from a SQL background, makes a ton of sense. This restructuring of code didn’t create new abilities that didn’t exist before but allowed for cleaner code to accomplish many common tasks.

If we look at the code below, we can see two pieces of code that return an array of all contacts with the name “Gabie”.

The first is how the code would look prior to LINQ.

The second is how the code could be restructured using LINQ.

The LINQ code is much simpler and concise. Both the LINQ version and the where / Lambda implementations simplify a lot of code and looping. Under the hood, they will have to do something similar, but the reduction in code helps make it easier to understand.

LINQ also enabled another significant feature of the .NET framework: EntityFramework.

EntityFramework didn’t come out at the exact same time (it was a little later with .NET 3.5 SP1), but because of this strongly typed query language, C# could create strongly typed database queries. This hadn’t existed before. Prior to LINQ, database queries were often just strings in code.

The introduction of LINQ wasn’t perfect, but a change this big most certainly was kind of a culture shock at the time. But today, I bet almost no one would want it removed from C#.

Series Overview

Introduction
.NET Framework 2.0 (Generics, Partial Classes, Nullable Types, Anonymous Methods)
.NET Framework 3.0/3.5 (WPF, WF, WCF, Auto-Implemented Properties)
.NET Framework 3.0 (LINQ)
.NET Framework 3.5 SP1 (ADO.NET Entity Framework)
.NET Framework 4.0 (Parallel, Dynamic)
.NET Framework 4.5 (Async)
.NET Core
.NET Core 2.1/2.2 (expression-bodied members, Local functions, Async Main)
.NET Core 3.0/3.1/Framework 4.7 (New Start, Performance, Switch Statements, Tuples, readonly, Using)
.NET Core 5 (Merge, Record Types, Top Level Statements)

Looking For More?

Sign up to receive useful software development tips and news from the Don't Panic Labs team.

You have successfully subscribed!

Share This