What is LINQ?
LINQ (Language Integrated Query) is uniform query syntax in C# and VB.NET to retrieve data from different sources and formats. It is integrated in C# or VB, thereby eliminating the mismatch between programming languages and databases, as well as providing a single querying interface for different types of data sources.
For example, SQL is a Structured Query Language used to save and retrieve data from a database. In the same way, LINQ is a structured query syntax built in C# and VB.NET to retrieve data from different types of data sources such as collections, ADO.Net DataSet, XML Docs, web service and MS SQL Server and other databases.
Advantages of LINQ
- Familiar language: Developers don’t have to learn a new query language for each type of data source or data format.
- Less coding: It reduces the amount of code to be written as compared with a more traditional approach.
- Readable code: LINQ makes the code more readable so other developers can easily understand and maintain it.
- Standardized way of querying multiple data sources: The same LINQ syntax can be used to query multiple data sources.
- Compile time safety of queries: It provides type checking of objects at compile time.
- IntelliSense Support: LINQ provides IntelliSense for generic collections.
- Shaping data: You can retrieve data in different shapes.