Here, we will learn about LINQ with its advantages and disadvantages and whether to use LINQ in our applications or not. We will also see LINQ architecture with its diagram.
So the Question is What is LINQ?
Linq stands for Language Integrated Query. We can use Linq in C# or VB.NET and it was introduced in .NET version 3.5. We can use Linq to query data to various data sources such as XML, SQL Database, Generics, ADO.NET, etc based on our requirement.
Linq, as it is available in System. Linq namespace and its a set of extension methods to query the data. Linq allows us to interact with any type of data.
We can use Linq with various data sources
- Linq to Objects
- Linq to Datasets
- Linq to SQL
- Linq to Entities
- Linq to XML
Why use LINQ?
Linq is quite simple, a higher level than SQL. As we all know that SQL is executed in the SQL Server or any other database while Linq is written in the code behind and provides full intellisense and also checks the type at compile time so it helps us to avoid runtime errors for the query.
Advantages of LINQ
- It provides us intellisense.
- The query is checked at compile time
- The query can be reused
- We can debug the query using the debugger
- It supports filtering, sorting with much less effort
Disadvantages of LINQ
- We cannot use stored procedure in LINQ
- Writing a complex query is a bit harder
- Performance degraded if query not written properly
- We have to build the DDL every time the changes are done in the query.