LINQ Programming
About the Author
Joe Mayo has been developing software since 1986. His experience includes assorted main-frame, desktop, and web development on different operating systems, including UNIX and Windows. He got started in the early days of .NET, back in July 2000, when .NET was still a pre-alpha product. These days, Joe owns Mayo Software Consulting, Inc., serving customers with custom software development and specializing in Microsoft .NET technology.
In addition to professional activities, Joe enjoys contributing to the community. He operates the C# Station website, and he blogs, twitters, and posts to various .NET-related forums. He also has written four other .NET technology books and numerous articles. Joe is honored to have received multiple Microsoft MVP awards.
About the Technical Editor
Tony Gravagno started programming in high school in 1978 and added the .NET Framework to his toolkit in 2002. He describes Nirvana as a place where he can make a living writing cool and useful code related to his other passionsforeign language, astronomy, and other sciences. When hes not reading tech docs or running his business, Nebula Research and Development, he enjoys spending time with his wife, Joleen, and his godsons, Danny and Michael.
LINQ Programming
Joe Mayo
Copyright 2009 by The McGraw-Hill Companies, Inc. All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher.
ISBN: 978-0-07-159784-5
MHID: 0-07-159784-0
The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-159783-8 MHID: 0-07-159783-2.
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. To contact a representative please visit the Contact Us page at www.mhprofessional.com .
Information has been obtained by McGraw-Hill from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, McGraw-Hill, or others, McGraw-Hill does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information.
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc. (McGraw-Hill) and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hills prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED AS IS. McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
To June Blossom Mayo
Contents at a Glance
Contents
Foreword
LINQ is a new technology that will help developers get more work done in less time using code that is easy to maintain. It provides a single, easy to understand query model for working with a wide range of data sources, from relational databases, to XML, to the generic collections in our programs. LINQ even includes an extensible data model that allows developers to query any arbitrary data source. Never before has it been so easy for developers to write queries against a wide range of data sources using code that is so clean, succinct, and flexible.
To reap these benefits, however, you will need a good map that lays out the new territory exposed by the LINQ architecture. Before they can fully understand LINQ, most developers are going to need to become acquainted with several new concepts. The basics of LINQ are easy to understand, but gaining a deep understanding of the conceptual framework behind LINQ requires some work.
This book provides developers with a clear, easy to read map that details the LINQ architecture and supplies us with a well thought out overview of the terrain. Joe Mayo is not only an excellent engineer, but also an excellent writer with an organized and very logical mind. He is the ideal guide to the new and exciting world of LINQ development.
Joe starts out this excellent book with an explanation of the fundamental syntactical elements introduced in C# 3.0 that form the foundation for LINQ. Building on these principles, he goes on to explain how to write query expressions, explaining the syntax in clear, well-written, and logically structured prose. From there, he goes on to cover all the key features of LINQ, include LINQ to SQL, LINQ to XML, and LINQ to DataSets.
The latter half of the book contains an excellent and highly valuable chapter on creating LINQ providers. Near the end of the text, Joe gifts us with an excellent chapter on how to design LINQ applications. This guide to many important LINQ best practices will no doubt become one of the most utilized and favorite sections of this very useful book.
I have read several LINQ books. This text is the best laid out, and the most thoughtful and thorough examination of this subject that I have seen. The book that you hold in your hands is a superior guide to a new world of programming. LINQ is both a practical tool that will help us get our work done more quickly, and also a beautifully designed tool that yields many wonders for those who take the time to study it in-depth. This book is an excellent guide to that wondrous new world, written by an expert working at the peak of his powers. We are all lucky to have such a great new guide to this exciting territory.
Next page