O'Reilly logo

Beginning Visual C# 2012 Programming by Christian Nagel, Daniel Kemper, Morgan Skinner, Jon Reid, Jacob Vibe Hammer, Karli Watson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 23

Introduction to LINQ

What You Will Learn in this Chapter

  • Coding a LINQ query and the parts of a LINQ query statement
  • Using LINQ method syntax versus LINQ query syntax
  • Ordering query results, including ordering on multiple levels
  • When and how to use LINQ aggregate operators
  • Using projection to create new objects in queries
  • Using the Distinct(), Any(), All(), First(), FirstOrDefault(), Take(), and Skip() operators
  • Grouping queries
  • Setting operators and joins

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

You can find the wrox.com code downloads for this chapter at www.wrox.com/remtitle.cgi?isbn=9781118314418 on the Download Code tab. The code is in the Chapter 23 download and individually named according to the names throughout the chapter.

This chapter introduces Language Integrated Query (LINQ). LINQ is an extension to the C# language that integrates data query directly into the programming language itself. LINQ solves the problem of dealing with very large collections of data.

In the past, this sort of work required writing a lot of looping code, and additional processing such as sorting or grouping the found objects required even more code, sometimes mixing in a different query language such as SQL (Structured Query Language) typically found in relational databases. LINQ frees you from having to write this extra looping code to filter and sort. It enables you to focus on the objects that matter to your program.

In addition to providing an elegant query language that enables ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required