LINQ Introduction - What is LINQ & Why we use LINQ

Here we will learn introduction to linq, what is linq in c# /, why we use linq in c# /, linq architecture with diagram, advantages of linq, disadvantages of linq.

What is LINQ?

The full form of LINQ is Language Integrated Query and it was introduced in .NET Framework 3.5 to query the data from different data sources such as collectionsgenerics, XML Documents, ADO.NET Datasets, SQL, Web Service, etc. in C# and VB.NET. The LINQ will provide a rich, standardized query syntax in .NET programming languages such as C# and VB.NET to allow the developers to interact with any type of data.


In c# or, the LINQ functionality can be achieved by importing System.Linq namespace in our application. Generally, the LINQ will contain a set of extension methods that allow you to query the data source objects directly in the code based on our requirements.

LINQ Architecture

Following diagram will represent the complete architectural view of LINQ.


LINQ Architectural View Diagram

As mentioned in the above diagram following are the various types of LINQ objects available in c# and


  • LINQ to Objects
  • LINQ to Datasets
  • LINQ to SQL
  • LINQ to Entities
  • LINQ to XML

We would be covering these topics in detail in the later part of the series.

Why we need to use LINQ?

Now the question arise why should we use LINQ? What’s so different in LINQ that everyone would want to use it in their application and not the SQL? Well the answer is quite simple as LINQ is simpler, tidier, and higher-level than SQL. When it comes to querying databases, In most cases, LINQ is more productive querying language than SQL.


Also we have the benefit of intellisense as LINQ query is written in code behind and moreover it has full type checking at compile time so we can catch any error in compile time itself. In c# or writing queries is more fun in LINQ but it has its advantages as well as disadvantages which are as follows:

Advantages of LINQ

Following are the advantages of using LINQ in our applications.


  1. It has full type checking at compile time.
  2. It has intellisense, so we can avoid silly errors.
  3. Its query can be reused.
  4. We can debug it using .NET debugger.
  5. It supports filtering, sorting, ordering, grouping with much less effort. 

Disadvantages of LINQ

Following are the drawbacks of using LINQ in our applications.


  1. Since it was written in the code we cannot make use of Cache execution plan which is a SQL feature as we do in stored procedure.
  2. Writing complex queries in LINQ is a bit tedious as compared to SQL.
  3. If the query is not written properly then performance is degraded.
  4. We have to build the project and deploy the DLL every time some change is done in the query.

LINQ has its own advantages and disadvantages so based on requirements we can use linq in our applications.