What is LINQ in C#?
What is LINQ in C# and why is use this LINQ in C# program?
An enthusiastic, adaptive, and fast-learning person with a broad and acute interest in the discovery of new innovative drugs, I particularly enjoy collaborating with scientists from different disciplines to develop new skills and solve new challenges.
Ravi Vishwakarma
24-Sep-2021LINQ is actually an extension of the .NET Framework, which provides the facility to fire collections of data in the C# programming language by creating queries similar to SQL Query. As a result in the same way we can retrieve data on the basis of specific Criteria by firing LINQ Query on Collections of Data in C# Program similar to SQL Query. The specialty of LINQ is that by using LINQ Queries, we can query data in a similar way not only from Databases but also from Collections of Program Objects, XML Documents, and other types of Data Sources.
Advantages of LINQ
1. It has full type checking at compile time.
2. We can avoid errors because it has intelligence.
3. Its query can be reused.
4. We can debug using a .NET debugger.
5. It supports filter, sorting, ordering, and grouping with much less effort.
Disadvantages of LINQ
1. Since it was written in the code we cannot make use of the Cache execution plan which is a SQL feature as we do in the stored procedure.
2. If the query is not written properly then performance is degraded.
Example
Output