We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Technology

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What is a Language Integrated Query?

By Jessica Seminara
Updated: May 17, 2024
Views: 6,480
Share

Language integrated query (LINQ) provides the ability to seamlessly integrate declarative query syntax into imperative languages, primarily C# and VB.NET. The development of LINQ solved the problems developers working in object-oriented environments encountered when performing queries. It was introduced as part of the Microsoft® .NET Framework version 3.5 in November 2007, and in Visual Studio® codename "Orcas."

Prior to the creation of language integrated query, .NET languages had no native way to query relational databases or XML documents. Developers writing in these languages had to embed SQL or XQuery respectively as strings, and manually map resulting data to .NET objects. Embedded query strings and mappings could not be validated by .NET compilers, allowing potential errors to be discovered at run time.

Another problem developers faced before language integrated query was that .NET languages had only objected-oriented syntax to query collections of .NET objects. Typically, the developer would iterate over a whole source collection, building new result collections based on search criteria. The developer could also transform the data while building the result collections. This approach was cumbersome; a simple select query written in C# or VB would require at least five lines of code, whereas the same query would require one line of code in a query language.

The challenges of querying within an object-oriented environment gave Microsoft the impetus to create LINQ. LINQ provides a query syntax reminiscent of SQL to be used in-line with C# or VB, complete with static type checking. When querying .NET collections, instead of using nested loops, developers can use LINQ syntax to select items and transform data. Among other advantages, this results in fewer lines of code as compared to purely object-oriented syntax.

When accessing external data sources, LINQ and supporting components remove the need for embedded query languages and data mappings within a .NET language itself. In order to perform data mapping, LINQ depends on components called LINQ providers. LINQ-to-Objects is the stock provider that enables LINQ to access .NET collections. Similarly, there are providers to access relational databases and XML documents. Most of these providers are third-party components not included in the .NET Framework. Regardless of the provider used, all queries use the same LINQ syntax.

Between the language integrated query syntax and the providers is a library of query operators added to the .NET Framework as a part of the LINQ facilities. These operators perform such tasks as filtering, ordering, set theory operations, and aggregation. As these operators are part of the .NET Framework, they can also be used without LINQ if the developer so chooses.

Share
WiseGeek is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.

Editors' Picks

Discussion Comments
Share
https://www.wisegeek.net/what-is-a-language-integrated-query.htm
Copy this link
WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.

WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.