LINQ to Objects Using C# 4.0: Using and Extending LINQ to Objects and Parallel LINQ (PLINQ)

The Only Complete, Realistic, Example-Rich Guide to LINQ to Objects, PLINQ, and C# 4.0

 

Using LINQ to Objects, .NET developers can write queries over object collections with the same deep functionality that was once available only with SQL and relational databases. Now, for the first time, developers have a comprehensive and authoritative guide to applying LINQ to Objects in real-world software. Microsoft MVP Troy Magennis introduces state-of-the-art techniques for working with objects more elegantly and efficiently–and writing code that is exceptionally powerful, robust, and flexible.

 

Drawing on his unsurpassed experience coding LINQ software and hosting the popular HookedonLINQ.com site, Magennis presents timely, realistic solutions to a wide spectrum of development challenges. You’ll begin with five-minute quick-starts that walk you through LINQ to Objects’ key features. Next, you’ll drill down to detailed techniques for applying these features with C# 4.0 and C# 3.0–including code examples that reflect the realities of production development. Coverage includes:

 

·   Writing basic LINQ queries with C#: filtering, projecting, and sequencing data from in-memory collections

·   Mastering advanced techniques for grouping and joining data

·   Taking full advantage of LINQ’s standard query and set-based operators

·   Creating all four main types of custom operators

·   Including standard error handling in custom operators

·   Writing more fluent, readable LINQ queries with C# 4.0’s dynamic language features

·   Combining LINQ with COM-Interop to access data sources such as Microsoft Excel

·   Using Parallel LINQ to Objects (PLINQ) to optimize queries for multi-core processors

·   Integrating the best LINQ to Objects patterns into your day-to-day coding

1125409214
LINQ to Objects Using C# 4.0: Using and Extending LINQ to Objects and Parallel LINQ (PLINQ)

The Only Complete, Realistic, Example-Rich Guide to LINQ to Objects, PLINQ, and C# 4.0

 

Using LINQ to Objects, .NET developers can write queries over object collections with the same deep functionality that was once available only with SQL and relational databases. Now, for the first time, developers have a comprehensive and authoritative guide to applying LINQ to Objects in real-world software. Microsoft MVP Troy Magennis introduces state-of-the-art techniques for working with objects more elegantly and efficiently–and writing code that is exceptionally powerful, robust, and flexible.

 

Drawing on his unsurpassed experience coding LINQ software and hosting the popular HookedonLINQ.com site, Magennis presents timely, realistic solutions to a wide spectrum of development challenges. You’ll begin with five-minute quick-starts that walk you through LINQ to Objects’ key features. Next, you’ll drill down to detailed techniques for applying these features with C# 4.0 and C# 3.0–including code examples that reflect the realities of production development. Coverage includes:

 

·   Writing basic LINQ queries with C#: filtering, projecting, and sequencing data from in-memory collections

·   Mastering advanced techniques for grouping and joining data

·   Taking full advantage of LINQ’s standard query and set-based operators

·   Creating all four main types of custom operators

·   Including standard error handling in custom operators

·   Writing more fluent, readable LINQ queries with C# 4.0’s dynamic language features

·   Combining LINQ with COM-Interop to access data sources such as Microsoft Excel

·   Using Parallel LINQ to Objects (PLINQ) to optimize queries for multi-core processors

·   Integrating the best LINQ to Objects patterns into your day-to-day coding

47.99 In Stock
LINQ to Objects Using C# 4.0: Using and Extending LINQ to Objects and Parallel LINQ (PLINQ)

LINQ to Objects Using C# 4.0: Using and Extending LINQ to Objects and Parallel LINQ (PLINQ)

by Troy Magennis
LINQ to Objects Using C# 4.0: Using and Extending LINQ to Objects and Parallel LINQ (PLINQ)

LINQ to Objects Using C# 4.0: Using and Extending LINQ to Objects and Parallel LINQ (PLINQ)

by Troy Magennis

eBook

$47.99 

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

The Only Complete, Realistic, Example-Rich Guide to LINQ to Objects, PLINQ, and C# 4.0

 

Using LINQ to Objects, .NET developers can write queries over object collections with the same deep functionality that was once available only with SQL and relational databases. Now, for the first time, developers have a comprehensive and authoritative guide to applying LINQ to Objects in real-world software. Microsoft MVP Troy Magennis introduces state-of-the-art techniques for working with objects more elegantly and efficiently–and writing code that is exceptionally powerful, robust, and flexible.

 

Drawing on his unsurpassed experience coding LINQ software and hosting the popular HookedonLINQ.com site, Magennis presents timely, realistic solutions to a wide spectrum of development challenges. You’ll begin with five-minute quick-starts that walk you through LINQ to Objects’ key features. Next, you’ll drill down to detailed techniques for applying these features with C# 4.0 and C# 3.0–including code examples that reflect the realities of production development. Coverage includes:

 

·   Writing basic LINQ queries with C#: filtering, projecting, and sequencing data from in-memory collections

·   Mastering advanced techniques for grouping and joining data

·   Taking full advantage of LINQ’s standard query and set-based operators

·   Creating all four main types of custom operators

·   Including standard error handling in custom operators

·   Writing more fluent, readable LINQ queries with C# 4.0’s dynamic language features

·   Combining LINQ with COM-Interop to access data sources such as Microsoft Excel

·   Using Parallel LINQ to Objects (PLINQ) to optimize queries for multi-core processors

·   Integrating the best LINQ to Objects patterns into your day-to-day coding


Product Details

ISBN-13: 9780321637178
Publisher: Pearson Education
Publication date: 03/02/2010
Series: Addison-Wesley Microsoft Technology Series
Sold by: Barnes & Noble
Format: eBook
Pages: 336
File size: 21 MB
Note: This product may take a few minutes to download.
Age Range: 18 Years

About the Author

Troy Magennis has been awarded Microsoft’s MVP status in C# for the last 5 years and has spoken at Microsoft TechEd, user groups, and conferences on .NET software development topics. He founded and runs HookedonLINQ.com, which covers LINQ in detail and has established him as a leader in the worldwide LINQ community. Magennis has led and participated in many of Australia’s biggest and most successful .NET products, from shrink-wrapped products sold to multi-nationals like Toyota and GM, to in-house bank financial systems.

Table of Contents

Foreword . . . x

Preface . . . xii

Acknowledgments . . . xix

About the Author . . . xx

Chapter 1: Introducing LINQ . . . 1

What Is LINQ? . . . 1

The (Almost) Current LINQ Story . . . 3

LINQ Code Makeover–Before and After Code Examples . . . 5

Benefits of LINQ . . . 12

Summary . . . 15

References . . . 15

Chapter 2: Introducing LINQ to Objects . . . 17

LINQ Enabling C# 3.0 Language Enhancements . . . 17

LINQ to Objects Five-Minute Overview . . . 30

Summary . . . 39

References . . . 39

Chapter 3: Writing Basic Queries . . . 41

Query Syntax Style Options . . . 41

How to Filter the Results (Where Clause) . . . 49

How to Change the Return Type (Select Projection) . . . 54

How to Return Elements When the Result Is a Sequence (Select Many) . . . 59

How to Get the Index Position of the Results . . . 61

How to Remove Duplicate Results . . . 62

How to Sort the Results . . . 63

Summary . . . 73

Chapter 4: Grouping and Joining Data . . . 75

How to Group Elements . . . 75

How to Join with Data in Another Sequence . . . 93

Summary . . . 119

Chapter 5: Standard Query Operators . . . 121

The Built-In Operators . . . 121

Aggregation Operators–Working with Numbers . . . 123

Conversion Operators–Changing Types . . . 131

Element Operators . . . 144

Equality Operator–SequenceEqual . . . 153

Generation Operators–Generating Sequences of Data . . . 155

Merging Operators . . . 159

Partitioning Operators–Skipping and Taking Elements . . . 160

Quantifier Operators–All, Any, and Contains . . . 164

Summary . . . 171

Chapter 6: Working with Set Data . . . 173

Introduction . . . 173

The LINQ Set Operators . . . 174

The HashSet<T> Class . . . 185

Summary . . . 192

Chapter 7: Extending LINQ to Objects . . . 195

Writing a New Query Operator . . . 195

Writing a Single Element Operator . . . 196

Writing a Sequence Operator . . . 208

Writing an Aggregate Operator . . . 216

Writing a Grouping Operator . . . 222

Summary . . . 232

Chapter 8: C# 4.0 Features . . . 233

Evolution of C# . . . 233

Optional Parameters and Named Arguments . . . 234

Dynamic Typing . . . 243

COM-Interop and LINQ . . . 251

Summary . . . 260

References . . . 260

Chapter 9: Parallel LINQ to Objects . . . 261

Parallel Programming Drivers . . . 261

Multi-Threading Versus Code Parallelism . . . 264

Parallelism Expectations, Hindrances, and Blockers . . . 267

LINQ Data Parallelism . . . 271

Writing Parallel LINQ Operators . . . 289

Summary . . . 301

References . . . 301

Glossary . . . 303

Index . . . 307

From the B&N Reads Blog

Customer Reviews