Here we will learn introduction to linq, what is linq in c# / asp.net, why we use linq in c# / asp.net, linq architecture with diagram, advantages of linq, disadvantages of 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 collections, generics, 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 vb.net, 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.
Following diagram will represent the complete architectural view of LINQ.
As mentioned in the above diagram following are the various types of LINQ objects available in c# and vb.net.
We would be covering these topics in detail in the later part of the series.
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 vb.net writing queries is more fun in LINQ but it has its advantages as well as disadvantages which are as follows:
Following are the advantages of using LINQ in our applications.
Following are the drawbacks of using LINQ in our applications.
LINQ has its own advantages and disadvantages so based on requirements we can use linq in our applications.