LINQ (Language Integrated Query) is uniform query syntax to retrieve data from different sources and formats supported in C# and VB.Net. LINQ helps us to retrieve and filter data in a convenient and uniform way from different sources like SQL databases, ADO .NET Datasets, XML documents and .NET collections.

Namespace : System.Linq

In the above example, from the vehicles collection, vehicle list containing string “Car” is selected. However, it is to be noted that query is executed when the query variable isĀ iterated, not when the query is assigned to the query variable. This is known as deferred execution of LINQ query.

In above query, query is forced to execute immediately as the result is taken as List by using the ToList() exetnesion method. This is known as immediate execution.