reading-notes

LINQ (Language Integrated Query)

LINQ (Language Integrated Query) is a feature in C# that provides a powerful and expressive way to query and manipulate data from different data sources, such as collections, databases, XML, and more. It allows you to write queries using a uniform syntax, regardless of the data source.

You can write LINQ queries in C# for SQL Server databases, XML documents, ADO.NET Datasets, and any collection of objects that supports IEnumerable or the generic IEnumerable interface. LINQ support is also provided by third parties for many Web services and other database implementations.

Three Parts of a Query Operation

All LINQ query operations consist of three distinct actions:

Queries in LINQ specify what information to retrieve from the data source and can include filtering, sorting, and shaping operations. Queries are stored in query variables and are executed when iterated over in a foreach statement.

LINQ queries exhibit deferred execution, meaning that the actual execution and retrieval of data occur when the query variable is iterated over. However, immediate execution can be forced using methods like Count(), ToList(), or ToArray().

# The “Basic LINQ Query Operations” article provides an overview of common operations used in LINQ (Language Integrated Query) queries in C#.

Walkthrough: Writing Queries in C#