Here we will learn the 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, etc. in detail with examples in c# and vb.net.
The complete 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 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.
The following diagram will represent the complete architectural view of LINQ.
As mentioned in the above diagram, the various LINQ objects are available in c# and vb.net.
We will be covering these topics in detail in the later part of the series.
Now the question arises why we should 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 a more productive querying language than SQL.
Also, we have the benefit of IntelliSense as the LINQ query is written in code behind, and 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 advantages and disadvantages, so based on requirements, we can use LINQ in our applications.