Chapter 4. Language Integrated Query (LINQ) and Lambda Expressions
4.0 Introduction
Language Integrated Query (LINQ) is a great way to access data from many different sources. LINQ provides a single querying model that can operate against different data domains individually or all together in a single query. LINQ brings the ability to query data to .NET languages, and some of the languages have provided extensions to make its use even more intuitive. One of these languages is C#; there are a number of extensions to the language in C# that help to facilitate querying in a rich and intuitive manner.
Traditional object-oriented programming is based on an imperative style wherein developers describe in detail not only what they want to happen, but also exactly how it should be performed through code. LINQ helps to take coding down a more declarative path that facilitates describing what the developer wants to do instead of detailing how to accomplish the goal. LINQ also enables a more functional style of programming. These changes can dramatically shorten the amount of code it takes to perform some tasks. That said, object-oriented programming is still very much alive and well in C# and .NET, but for the first time the language is offering you the chance to choose the style of programming based on your needs. Note, however, that LINQ will not fit into every scenario and is not a replacement for good design or practice. You can write bad code using LINQ just as you can write bad object-oriented ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access