ebook img

Into Darkness PDF

601 Pages·2019·8.197 MB·English
by  RoberdsHolly
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Into Darkness

Praise for Essential LINQ “Essential LINQis the most comprehensive book I have read so far on LINQ tech- nology. Both Charlie and Dinesh have done an excellent job bringing their inter- nal expertise to developers through this book. The book starts with the basics of LINQ and delves deep into the LINQ Ocean. If you would like to learn the internals of LINQ technology and master it, this book is for you.” —Mahesh Chand, MVP, MCP, author and founder of C# Corner “LINQ is one of the most transformational technologies of .NET and will have a profound impact on how developers architect and code applications going for- ward. Essential LINQis an excellent book that will help you learn and under- stand LINQ, and enable you to immediately start applying it with your projects.” —Scott Guthrie, Corporate Vice President, .NET Developer Platform, Microsoft “Essential LINQ provides an excellent and cohesive overview of LINQ with emphasis on LINQ to Objects, LINQ to SQL, and LINQ to XML.” —Pat Helland, Partner Architect, Microsoft Corporation “Self-effacing, Charlie Calvert will tell you he is just lucky to hang around smart guys that let him explain things to others, but his straightforward, clear, and precise explanations will make LINQ one of your new best friends.” —Paul Kimmel, Microsoft MVP and author of LINQ Unleashed for C# “Something wonderful is happening. Developers are discovering the newly inte- grated ability to query in-memory collections such as arrays and lists, Datasets, XML, and relational databases directly from their .Net code. These collective capabilities, typically referred to as a paradigm shift, have already begun to shake foundations and open developers’ eyes to new possibilities. As the ini- tial waves of this shift take place, there exists a parallel need for understanding essential fundamentals and principles. “Essential LINQ” is the best written, most concise source from which to build your fundamental understanding of LINQ. Read this book!” —Ron Landers, Senior Technical Consultant, Right-Click Consulting, LLC “LINQ and its related language features will change how you program, and this book is a great way to learn and fully understand these new ideas.” —Rocky Lhotka, Principal Technology Evangelist, Magenic and author of the Expert C#/VB 2008 Business Objectsbooks “By focusing on LINQ to SQLand LINQ to XML, Charlie and Dinesh take the remarkable genius of C# 3.0’s LINQ and write about it in a way that is simple to understand, powerful to implement, and fully available for reference.” —Mark Michaelis, Chief Software Architect, IDesign/intelliTechture “This is a marvelous book. In a rare combination, it succeeds at being simulta- neously deep and accessible. Charlie and Dinesh are great story tellers who are uncompromising in giving you a full understanding of LINQ’s deepest princi- ples, while at the same time holding your hand to guide you every step of the way. With its personal and engaging style, this book gives you a well-crafted overview of the surface of the LINQ technologies, along with satisfying series aha’s that will help you think LINQ.” —Mads Torgersen, Senior Program Manager and C# Spec Author, Microsoft Corporation “Reading Essential LINQ will make you feel like you have members of the C# team standing over your shoulder, ready to answer questions as you explore LINQ. As you continue to read, Charlie and Dinesh take you deeper and deeper into how LINQ makes it easier for you to build more sophisticated applications than you’d ever dreamed of before. With every new section, you’ll have a greater understanding of how LINQ and, more specifically, LINQ to SQLtrans- form your code into expressive queries and updates.” —Bill Wagner, Co-Founder of SRT Solutions and author of More Effective C# Essential LINQ Microsoft .NET Development Series John Montgomery, Series Advisor Don Box, Series Advisor Brad Abrams, Series Advisor The award-winning Microsoft .NET Development Series was established in 2002 to provide professional developers with the most comprehensive and practical coverage of the latest .NET technologies. It is supported and developed by the leaders and experts of Microsoft development technologies, including Microsoft architects, MVPs, and leading industry luminaries. Books in this series provide a core resource of information and understanding every developer needs to write effective applications. Titles in the Series Brad Abrams, .NET Framework Standard Library James S. Miller and Susann Ragsdale, Annotated Reference Volume 1: Base Class Library and The Common Language Infrastructure Annotated Standard, Extended Numerics Library, 978-0-321-15489-7 978-0-321-15493-4 Brad Abrams and Tamara Abrams, .NET Framework Christian Nagel, Enterprise Services with the .NET Standard Library Annotated Reference, Volume 2: Framework: Developing Distributed Business Solutions Networking Library, Reflection Library, and XMLLibrary, with .NET Enterprise Services, 978-0-321-24673-8 978-0-321-19445-9 Brian Noyes, Data Binding with Windows Forms 2.0: Chris Anderson, Essential Windows Presentation Foundation Programming Smart Client Data Applications with .NET, (WPF), 978-0-321-37447-9 978-0-321-26892-1 Bob Beauchemin and Dan Sullivan, ADeveloper’s Guide to Brian Noyes, Smart Client Deployment with ClickOnce: SQLServer 2005, 978-0-321-38218-4 Deploying Windows Forms Applications with ClickOnce, Adam Calderon, Joel Rumerman, Advanced ASP.NET 978-0-321-19769-6 AJAX Server Controls: For .NET Framework 3.5, Fritz Onion with Keith Brown, Essential ASP.NET 2.0, 978-0-321-51444-8 978-0-321-23770-5 Eric Carter and Eric Lippert, Visual Studio Tools for Office: Steve Resnick, Richard Crane, Chris Bowen, Essential Using C# with Excel, Word, Outlook, and InfoPath, Windows Communication Foundation: For .NET Framework 978-0-321-33488-6 3.5, 978-0-321-44006-8 Eric Carter and Eric Lippert, Visual Studio Tools for Scott Roberts and Hagen Green, Designing Forms Office: Using Visual Basic 2005 with Excel, Word, Outlook, for Microsoft Office InfoPath and Forms Services 2007, and InfoPath, 978-0-321-41175-4 978-0-321-41059-7 Steve Cook, Gareth Jones, Stuart Kent, Alan Cameron Neil Roodyn, eXtreme .NET: Introducing eXtreme Wills, Domain-Specific Development with Visual Studio Programming Techniques to .NET Developers, DSLTools, 978-0-321-39820-8 978-0-321-30363-9 Krzysztof Cwalina and Brad Abrams, Framework Design Chris Sells and Michael Weinhardt, Windows Forms 2.0 Guidelines: Conventions, Idioms, and Patterns for Reusable Programming, 978-0-321-26796-2 .NET Libraries, Second Edition, 978-0-321-54561-9 Dharma Shukla and Bob Schmidt, Essential Windows Joe Duffy, Concurrent Programming on Windows, Workflow Foundation, 978-0-321-39983-0 978-0-321-43482-1 Sam Guckenheimer and Juan J. Perez, Software Guy Smith-Ferrier, .NET Internationalization: Engineering with Microsoft Visual Studio Team System, The Developer’s Guide to Building Global Windows 978-0-321-27872-2 and Web Applications, 978-0-321-34138-9 Anders Hejlsberg, Mads Torgersen, Scott Wiltamuth, Will Stott and James Newkirk, Visual Studio Team Peter Golde, The C# Programming Language, Third Edition, System:Better Software Development for Agile Teams, 978-0-321-56299-9 978-0-321-41850-0 Alex Homer and Dave Sussman, ASP.NET 2.0 Illustrated, Paul Yao and David Durant, .NET Compact Framework 978-0-321-41834-0 Programming with C#, 978-0-321-17403-1 Joe Kaplan and Ryan Dunn, The .NET Developer’s Guide to Paul Yao and David Durant, .NET Compact Framework Directory Services Programming, 978-0-321-35017-6 Programming with Visual Basic .NET, 978-0-321-17404-8 Mark Michaelis, Essential C# 3.0: For .NET Framework 3.5, 978-0-321-53392-0 For more information go to informit.com/msdotnetseries/ Essential LINQ Charlie Calvert Dinesh Kulkarni Upper Saddle River, NJ •Boston•Indianapolis•San Francisco New York •Toronto •Montreal •London•Munich•Paris•Madrid Capetown•Sydney•Tokyo •Singapore •Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The .NET logo is either a registered trademark or trademark of Microsoft Corporation in the United States and/or other countries and is used under license from Microsoft. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 [email protected] For sales outside the United States please contact: International Sales [email protected] Visit us on the Web: www.informit.com/msdotnetseries Library of Congress Cataloging-in-Publication Data: Calvert, Charles Essential LINQ / Charlie Calvert, Dinesh Kulkarni. — 1st ed. p. cm. ISBN 0-321-56416-2 (pbk. : alk. paper) 1. Microsoft LINQ. 2. C# (Computer program language) 3. Query languages (Computer science) 4. Microsoft .NET Framework. I.Kulkarni, Dinesh, 1968- II. Title. QA76.7.C35 2009 006.7’882—dc22 2008052508 Copyright © 2009 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA02116 Fax (617) 671 3447 ISBN-13: 978-0-321-56416-0 ISBN-10: 0-321-56416-2 Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana. First printing March 2009 This book is dedicated to my wife Margie. When authors dedicate their books to their wife or parents, I perhaps unfairly suspect them of a fail- ure of imagination or paucity of emotional range. I would have no prob- lem coming up with other worthies to whom I could dedicate this book. My good friends, such as David Intersimone, Lino Tadros, John Kaster, and Steve Teixeira, have been a joy to me for many years. I’m blessed with a wonderful father, and I would be happy to dedicate another book to him. My siblings, nieces, nephews, and other relatives are deserving of a dedication. So are my godparents, George and MaryAnn Kephart. I’ve recently been reintroduced to the Pacific Northwest, and I undoubtedly could never have written a word of this text were it not for the regular support I get from the mountains, forests, and waterways of this won- derful land. My many spiritual mentors—Christian, Buddhist, and Hindu—have been the very air I breathe for many years, and I could do nothing without them. I also lucked into—through no skill of my own, and despite all my best efforts to deny myself the privilege—a wonderful wife to whom I can never sufficiently offer enough thanks. Margie, I once again find myself dedicating a book to you, wishing only that this simple dedication were worthy of even some small portion of all that you have done for me. —Charlie Calvert Dedicated to the Lord for all he has given and continues to give. —Dinesh Kulkarni This page intentionally left blank Contents at a Glance Foreword xxi Acknowledgments xxv About the Authors xxix 1 Introduction 1 2 Getting Started 13 3 The Essence of LINQ 39 4 C# 3.0 Technical Overview 65 5 Writing Query Expressions 129 6 Query Operators 175 7 A Quick Tour of LINQ to SQL 231 8 Reading Objects with LINQ to SQL 247 9 Modifying Objects with LINQ to SQL 281 10 Using Stored Procedures and Database Functions with LINQ to SQL 319 11 Customizing Entity Persistence and Adding Business Logic 337 12 LINQ to Entities Overview 349 13 LINQ to XML: Creation 369 ix

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.