| By Dennis Hayes | Article Rating: |
|
| October 13, 2008 05:45 AM EDT | Reads: |
2,503 |
There are several flavors of LINQ (LINQ-to-Objects, LINQ-to-SQL, LINQ-to-XML, and others will be added in the future). Part II gets the reader started in LINQ by introducing LINQ-to-Objects.
Chapter 4, the first of the two chapters in this section, covers the basics of LINQ, introduces the reader to the LINQ Books example that is used in the rest of the book, and shows how LINQ integrates with WinForms and ASP.NET.
Chapter 5 delves deeper into LINQ, covering design patterns to use with LINQ, how to get the best performance with LINQ, and other things you need to make the most of LINQ; my favorite part was a section on how LINQ can be used with .csv text files. I will use that at work Monday.
Part III: LINQ to Relational Data
Chapter 6 moves from querying objects to querying SQL databases, starting with using the System.Data.Linq.Mapping attributes to map objects and properties to tables and columns, and using the DataContext to connect to databases. The authors also show how to start debugging using the datacontext logging capability as well as how to use the Microsoft Query Visualizer, which is a separate download for Visual Studio 2008. Both of these methods allow you to see the SQL statements that will be generated by LINQ. Learning about free tools like this is worth a big portion of the book's price. The chapter continues with the basics of querying, and explains lazy loading and how it affects writing and testing LINQ code.
Chapter 7 goes into more detail about mapping objects to databases and shows four methods for doing the mapping. The first method uses the mapping attributes discussed in chapter 6, the second uses external XML files, and the final two use the command-line SQLMetal tool and the graphical LINQ-to-SQL Designer tool. The goal here is to show the reader how LINQ-to-SQL works "under the covers." This chapter also covers IQueryable and expression trees, the entity life cycle, and using disconnected data. This is the kind of information you get from people who work with a technology and then write a book about it, but not from someone who writes technology books about technology that they may know, but don't work with every day.
Chapter 8 covers advanced LINQ-to-SQL topics including concurrency issues, pass-through queries, and using stored procedures and user-defined functions with LINQ. It then covers improving business-tier code by making use of compiled queries, partial classes and methods, and inheritance. The chapter closes with an explanation of why the simple mapping between objects and tables ceases to work well as databases become even slightly complex, and how adding a conceptual layer between objects and database entries fixes the problem. The authors briefly discuss how the forthcoming LINQ-to-Entities will work.
Part IV: LINQ-to-XML
Chapter 9 shows why previous ways of working with XML data are difficult, and how the new LINQ-to-XML API avoids most of those problems. It then describes the LINQ-to-XML classes in the .NET Framework, including the "VB-only" XML Literals. Most of the chapter is dedicated to showing how to access and manipulate XML files.
Chapter 10 continues where chapter 9 leaves off, going into more detail about ways to query XML, including working with elements, attributes, descendants, ancestors, and elements/nodes before/after self. It then covers using the standard query operators, including grouping and ordering, with XML. The chapter closes with XPath and XML transformations.
Chapter 11 describes six common scenarios that use LINQ-to-XML, and then shows how to implement each of the scenarios. The scenarios are creating objects from XML, creating XML from objects, creating XML with data from databases, filtering and mixing data from databases with data from XML, reading XML and updating a database, and transforming text files into XML. Using any of these cookbook scenarios would recoup the price of the book.
Part V: "LINQ" It Together
Part V is divided into two chapters representing two different sections. Chapter 12 shows how to extend LINQ. It starts by showing how the different flavors of LINQ such as LINQ-to-Objects and LINQ-to-SQL are actually implementations of LINQ. It goes on to show how to create custom query operators, and ends by implementing a LINQ to Amazon flavor of LINQ. How cool is that?
The final chapter in the book shows how and why to use LINQ as a data access layer, and how to do it in ways that give the full benefit of an n tier application.
Summary
This is one of my favorite LINQ books. It was written by people who know, use, and care about LINQ, and who want to see it used correctly. It spends as much or more time explaining why LINQ works the way it does, as it spends explaining what LINQ does. The book also sneaks in some best practices explained by people who know, use, and understand LINQ, SQL, and database access. Most books I skim through for new bits of information, but this is one I want to read cover to cover, because there seems to be something to learn on every page.
Published October 13, 2008 Reads 2,503
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Dennis Hayes
Dennis Hayes is a programmer at Georgia Tech in Atlanta Georgia where he writes software for the Adult Cognition Lab in the Psychology Department. He has been involved with the Mono project for over six years, and has been writing the Monkey Business column for over five years.
- Kindle 2 vs Nook
- Is Cloud Computing Like Teenage Sex?
- GovIT Expo Highlights Cloud Computing
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Cloud Computing Can Revitalize Your Career as Software Developer
- Ubuntu-based Open Source Linux Mint Tests KDE Version
- Yahoo! SVP Shelton Shugar to Discuss Innovation at Cloud Computing Expo
- Virtualization Journal "Readers' Choice Awards" Voting Is Now Open
- Einstein, Sharks and Clouds: IT Security in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Amazon Web Services Database in the Cloud
- Virtualization Expo Call for Papers Deadline December 15
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Is Cloud Computing Like Teenage Sex?
- 1st Annual GovIT Expo: Letter from the Technical Chair
- Ulitzer News: Search vs New Media
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Confessions of a Ulitzer Addict
- GovIT Expo Highlights Cloud Computing
- Twitter, Linked In, Ning and Ulitzer: Easy Personal Branding Strategy
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- The i-Technology Right Stuff
- Linux.SYS-CON.com Exclusive: Linus Discloses *Real* Fathers of Linux
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- Linus' Top Ten SCO Barbs
- A Closer Look at Damn Small Linux
- Netscape Co-Founder's 12 Reasons for Growth of Open Source
- Introducing "Cooperative Linux" - Linux for Windows, No Less
- *POINT - COUNTERPOINT SPECIAL* What's Wrong with the Open Source Community?
- Where Are RIA Technologies Headed in 2008?
- Linux.SYS-CON.com Exclusive: What Would UserLinux Look Like?
- i-Technology Viewpoint: The New Paradigm of IT Buying
- Is Linux Desktop-Ready Yet...or Not?




























