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 . It was introduced in .NET 3.5 and we can use it in C# or VB.NET based on our requirements. LINQ can be used to query data from different data sources such as Collections, Generics, XML Documents, ADO.NET Datasets, SQL Databases, Web-service etc. and It connects UI and data access layer.
Linq, as it appears in the System.Linq namespace and its a set of extension methods that allow you to query collections directly in code. LINQ is an acronym for "Language Integrated Query". LINQ adds a rich, standardized query syntax in .NET programming languages that allows developers to interact with any type of data.
Following diagram will represent the complete architectural view of linq.
There are various types of LINQ that we have as shown above in the pictorial representation.
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, LINQ is in most cases a significantly more productive querying language than SQL.
Also we have benefit of intellisense as linq query is written in code behind and moreover it has full type checking at compile time. So this helps us to avoid runtime errors as we can catch any error in compile time itself. 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.