Please enable Javascript to correctly display the contents on Dot Net Tricks!

Introduction

Posted On : 02 Feb 2015
Updated On : 10 Feb 2015
Total Views : 12266

LINQ stands for "Language Integrated Query" and pronounced as "LINK". LINQ was introduced with .NET Framework 3.5 including Visual Studio 2008, C# 3.0 and VB.NET 2008 (VB 9.0). It enables you to query the data from the various data sources like SQL databases, XML documents, ADO.NET Datasets, Web services and any other objects such as Collections, Generics etc. by using a SQL Query like syntax with .NET framework languages like C# and VB.NET.

Why LINQ

LINQ has full type checking at compile-time and IntelliSense support in Visual Studio, since it used the .NET framework languages like C# and VB.NET. This powerful feature helps you to avoid run-time errors.

LINQ also provides a uniform programming model (i.e. common query syntax) to query various data sources. Hence you don’t need to learn the different ways to query different data sources.

System.Linq namespace is necessary for writing LINQ queries and to implement it.

Advantages of LINQ

  1. It provides a uniform programming model (i.e. common query syntax) to query data sources (like SQL databases, XML documents, ADO.NET Datasets, Various Web services and any other objects such as Collections, Generics etc.)

  2. It has full type checking at compile-time and IntelliSense support in Visual Studio. This powerful feature helps you to avoid run-time errors.

  3. It supports various powerful features like filtering, ordering and grouping with minimum code.

  4. Its Query can be reused.

  5. It also allows debugging through .NET debugger.

Disadvantages of LINQ

  1. LINQ is not good to write complex queries like SQL.

  2. LINQ doesn’t take the full advantage of SQL features like cached execution plan for stored procedure.

  3. Performance is degraded if you don't write the LINQ query correctly.

  4. If you have done some changes in your query, you have to recompile it and redeploy its dll to the server.

What do you think?

In this article you have learned about LINQ and its advantages and disadvantages. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.