LINQ Unleashed: for C#


Foreword by Darryl Hogan, Architect Evangelist, Microsoft Corporation

Microsoft?s highly anticipated LINQ query technology makes it easy to retrieve any information programmatically from any data source, no matter where it comes from or how it?s stored. Using LINQ, developers can query objects, relational databases,

This is a definitive guide to getting real-world results with LINQ, using C# 3.0 and Visual Studio 2008. In LINQ Unleashed, ...

See more details below
$37.26 price
(Save 32%)$54.99 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (10) from $11.92   
  • New (5) from $34.34   
  • Used (5) from $11.92   
LINQ Unleashed: for C#

Available on NOOK devices and apps  
  • NOOK Devices
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK Study

Want a NOOK? Explore Now

NOOK Book (eBook)
$25.49 price
(Save 42%)$43.99 List Price


Foreword by Darryl Hogan, Architect Evangelist, Microsoft Corporation

Microsoft’s highly anticipated LINQ query technology makes it easy to retrieve any information programmatically from any data source, no matter where it comes from or how it’s stored. Using LINQ, developers can query objects, relational databases,

This is a definitive guide to getting real-world results with LINQ, using C# 3.0 and Visual Studio 2008. In LINQ Unleashed, Microsoft MVP Paul Kimmel covers every facet of LINQ programming, showing how LINQ can help you dramatically improve your productivity and build more reliable, maintainable applications.

Kimmel begins by reviewing the state-of-the-art C# programming techniques LINQ uses, including anonymous types, partial methods, and Lambda expressions. Next, using realistic examples and easy-to-adapt sample code, he details the most powerful new LINQ techniques for accessing objects, databases, and


  • Build efficient LINQ queries to .NET objects, SQL databases, and

    Utilize anonymous types to reduce design time, coding effort, and debugging time

  • Automatically generate .NET state machines with the new yield return construct
  • Master LINQ query syntax, operators, extension methods, sorting, grouping, aggregate and set operations, and more
  • Make the most of select—and use it in the business layer of your n-tier applications
  • Query relational data stored in Microsoft SQL Server
  • Use nullable types to eliminate unnecessary database access plumbing code
  • Use LINQ with ADO.NET 3.0 and Microsoft’s powerful new Entity Framework
  • Extract

    Automatically construct

    Query Active Directory by extendingLINQ

Introduction  1

Part I   Getting Ready for LINQ

1   Programming with Anonymous Types 5

2   Using Compound Type Initialization  29

3   Defining Extension and Partial Methods  61

4   yield return: Using .NET’s State Machine Generator  85

5   Understanding Lambda Expressions and Closures  97

6   Using Standard Query Operators  121

Part II LINQ for Objects

7   Sorting and Grouping Queries 137

8   Using Aggregate Operations 151

9   Performing Set Operations  167

10   Mastering Select and SelectMany  185

11   Joining Query Results  211

12   Querying Outlook and Active Directory  239

Part III   LINQ for Data

13   Querying Relational Data with LINQ 265

14   Creating Better Entities and Mapping Inheritance and Aggregation  289

15   Joining Database Tables with LINQ Queries  309

16   Updating Anonymous Relational Data  349

17   Introducing ADO.NET 3.0 and the Entity Framework  383

Part IV  LINQ for

18   Extracting Data from

19   Comparing LINQ to

20   Constructing

21   Emitting


22   Combining

23   LINQ to XSD Supports Typed


Read More Show Less

Product Details

  • ISBN-13: 9780672329838
  • Publisher: Sams
  • Publication date: 9/2/2008
  • Series: Unleashed Series
  • Pages: 527
  • Sales rank: 1,505,888
  • Product dimensions: 6.90 (w) x 9.00 (h) x 1.30 (d)

Meet the Author

Paul Kimmel is a four-time Microsoft MVP, the author of over a dozen books on object oriented programming and UML, including three books on Microsoft .NET, a columnist for,,,, and, a cofounder of the Greater Lansing Area .NET Users Group (, East Lansing and Flint), a full-time software developer, and sometimes pilot. Paul still lives and works in the greater Lansing, Michigan, area (and hasn’t given up on the economy). After 15 years of independent consulting, Paul now works for EDS as an application architect.

Read More Show Less

Read an Excerpt


By the time you are holding this book in your hands, I will have 30 years in since the first time I wrote some code. That code was ROM-BASIC on a TRS-80 in Washington grammar school in Owosso, Michigan, and I was in the fifth grade. Making the "tank" slide back and forth shooting blips across the screen was neat. Changing the code to change blip speeds and numbers of targets was exhilarating. Three decades later and I get more excited each passing year. There are great technologies on the horizon like Microsoft Surface, Popfly, and LINQ. This book is about LINQ, or Language INtegrated Query.

LINQ is a SQL-like language for C#. When I first saw it, I didn't like it. My first impression was that someone had glommed on a bastardization of C# and it was ugly like SQL can get. I didn't like it because I didn't understand it. However, I gave LINQ a second chance (as I want you to do) and discovered that LINQ is thoroughly integrated, tremendously powerful, and almost as much fun as a Tesla Roadster or doing hammerheads in an Extra 300L.

The query capabilities of LINQ are extended to objects, SQL, DataSets,

LINQ and its underpinnings are powerful and challenging, and in this book you will get what you need to know to completely understand all that makes LINQ work and begin using it immediately. You will learn about anonymous methods, extension methods, Lambda Expressions, state machines, how generics and the CodeDOM play a big role in powerful tools like LINQ, and writing LINQ queries and why you will want to do it in the bigger, grander scheme of things. You will also learn how to save a ton of time and effort by nothard-coding those elements that you will no longer need or want to hard-code, and you will have a better grasp of how LINQ fits into n-tier architectures without breaking guidelines that have helped you succeed to date.

Brought to you by a four-time Microsoft MVP and columnist for over a decade, LINQ Unleashed for C# will teach you everything you need to know about LINQ and .NET 3.5 features and how to be more productive and have more fun than ever before.Conventions Used in This Book

The following typographic conventions are used in this book:

Code lines, commands, statements, variables, and text you see onscreen appear in a monospace typeface.

Occasionally in listings bold is used to draw attention to the snippet of code being discussed.

Placeholders in syntax descriptions appear in an italic monospace typeface. You replace the placeholder with the actual filename, parameter, or whatever element it represents.

Italics highlight technical terms when they're being defined.

A code-continuation icon is used before a line of code that is really a continuation of the preceding line. Sometimes a line of code is too long to fit as a single line on the page. If you see before a line of code, remember that it's part of the line immediately above it.

The book also contains Notes, Tips, and Cautions to help you spot important or useful information more quickly.

© Copyright Pearson Education. All rights reserved.

Read More Show Less

Table of Contents

Pt. I Getting ready for LINQ

1 Programming with anonymous types 5

2 Using compound type initialization 29

3 Defining extension and partial methods 61

4 yield return : using .NET's state machine generator 85

5 Understanding Lambda expressions and closures 97

6 Using standard query operators 121

Pt. II LINQ for objects

7 Sorting and grouping queries 137

8 Using aggregate operations 151

9 Performing set operations 167

10 Mastering Select and SelectMany 185

11 Joining query results 211

12 Querying Outlook and Active Directory 239

Pt. III LINQ for data

13 Querying relational data with LINQ 265

14 Creating better entities and mapping inheritance and aggregation 289

15 Joining database tables with LINQ queries 309

16 Updating anonymous relational data 349

17 Introducing ADO.NET 3.0 and the entity framework 383


18 Extracting data from XML 415

19 Comparing LINQ to XML with other XML technologies 437

20 Constructing XML from non-XML data 453

21 Emitting XML with the XmlWriter 463

22 Combining XML with other data models 469

23 LINQ to XSD supports typed XML programming 485

Index 499

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)