With LINQ, you can use the same syntax to retrieve data from any data source:
var query = from e in employees where e.id == 1 select e.name
This is not pseudocode; this is LINQ syntax, and it's very similar to SQL. The LINQ team's goal was not to add yet another way to access data, but to provide a native, integrated set of instructions to query any kind of data source. Using C# keywords, we can write data access code as part of C#, and the C# compiler will be able to enforce type safety and even logical consistency. LINQ provides a rich set of instructions to implement complex queries that support data aggregation, joins, sorting, and much more.
Figure 1 presents an overview of LINQ functionality. The top level shows the languages that provide native support for LINQ. Currently, only C# 3.0 and Visual Basic 9.0 offer complete support for LINQ.
The middle level represents the three main parts of the LINQ project:
IEnumerable<T>interface. These queries are performed against in-memory data.
DataSetsupports queries by using ADO.NET data sets and data tables. LINQ to Entities is a Microsoft ORM solution, allowing developers to use Entities (an ADO.NET 3.0 feature) to declaratively specify the structure of business objects and use LINQ to query them.
NOTE
I don't cover LINQ to Entities because the ADO.NET Entity Framework is an ADO.NET 3.0 feature, and is not yet as mature as other technologies that can be used with LINQ.
Now let's see what you need to work with LINQ.
18.220.96.214