Language Integrated
Query (LINQ)
What is LINQ?
• Language-Integrated Query (LINQ) is a powerful set of
technologies based on the integration of query capabilities
directly into the C# language. LINQ Queries are the first-
class language construct in C# .NET, just like classes,
methods, events. The LINQ provides a consistent query
experience to query objects (LINQ to Objects), relational
databases (LINQ to SQL), and XML (LINQ to XML).
• LINQ (Language Integrated Query) is uniform query syntax
in C# and VB.NET to retrieve data from different sources
and formats. It is integrated in C# or VB, thereby
eliminating the mismatch between programming languages
and databases, as well as providing a single querying
interface for different types of data sources.
• For example, SQL is a Structured Query Language used
to save and retrieve data from a database. In the same
way, LINQ is a structured query syntax built in C# and
VB.NET to retrieve data from different types of data
sources such as collections, ADO.Net DataSet, XML
Docs, web service and MS SQL Server and other
databases.
• LINQ queries return results as objects. It enables you
to uses object-oriented approach on the result set and
not to worry about transforming different formats of
results into objects.
• LINQ to SQL offers an infrastructure (run-time) for the management of
relational data as objects. It is a component of version 3.5 of the .NET
Framework and ably does the translation of language-integrated queries
of the object model into SQL. These queries are then sent to the database
for the purpose of execution. After obtaining the results from the
database, LINQ to SQL again translates them to objects.
• For most ASP.NET developers, LINQ to SQL (also known as DLINQ) is an
electrifying part of Language Integrated Query as this allows querying
data in SQL server database by using usual LINQ expressions. It also
allows to update, delete, and insert data, but the only drawback from
which it suffers is its limitation to the SQL server database. However,
there are many benefits of LINQ to SQL over ADO.NET like reduced
complexity, few lines of coding and many more.
Below is a diagram showing the
execution architecture of LINQ to SQL.
Reference
• LINQ - SQL (tutorialspoint.com)
• LINQ Query Syntax (tutorialsteacher.com)
• Language-Integrated Query (LINQ) (C#) | Microsoft Learn