Using C# LINQ - A Practical Overview
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Introduction
The C# programming language is quite popular with developers, in large part because of its many powerful and intuitive language features. One of these impressive (and fun, in a nerdy way) features is LINQ.
What is LINQ?
LINQ is a libary used to execute queries directly in C# syntax against many types of data. It is implemented as a set of extension methods on the IEnumerable<T>
interface.
NOTE: More informaiton on extension methods and
IEnumerable<T>
can be found in the LINQ Background Topics course.
LINQ != SQL
The acronym LINQ stands for Language Integrated Query. LINQ syntax is roughly derived from SQL. New C# developers often misinterpret this to mean that LINQ is a database access API. Although it is true that LINQ was conceived as a way to access data in a database from code, that is not the extent of its utility.
The LINQ paradigm
The LINQ paradigm describes a method for programmatically accessing and manipulating any data, independent of the source. There are many implementations of LINQ, each written to access a different kind of data source. Some of the common ones include: LINQ to SQL, LINQ to XML, and LINQ to Objects.
LINQ to Objects
Although this course works with LINQ to Objects, many of the concepts learned here can be applied to other LINQ implementations. LINQ to Objects provides access to data stored in C# collections such as lists and arrays.