Mastering LINQ
The big mistake is to feel your way in. You'll end up transliterating SQL queries
into LINQ, with horrible results! Taking a little time out to learn the querying
language properly will pay great dividends. LINQ has a more rewarding learning curve
than SQL: while it takes longer to learn the basics, it takes less time to master.
LINQ is largely free of the nuances that plague SQL and can be considered
a higher-level querying language.
Books are an excellent way to learn. If you're in a hurry—and consider yourself
an intermediate or advanced developer—the LINQ Pocket Reference will rapidly teach you all the essentials
to become competent in querying. This small book is written by the author of LINQPad
and is an extract from C# 3.0 in a
Nutshell. It covers all aspects of query syntax, every query operator,
how to query both local collections and databases, how to use all features of LINQ
to XML, how to mix query and method syntax, and how perform every kind of join and
subquery. And you can read it in an afternoon! All the examples from the LINQ Pocket
Reference are preloaded into LINQPad, so you can work through them interactively.
It doesn't get any easier!
There are also a number of well-reviewed larger books on LINQ, including LINQ in
Action (Manning), and Pro LINQ (Apress). O'Reilly have recently released a good
title specifically on Entity Framework (Programming Entity Framework). And Jon Skeet
has written an excellent book on C# 2.0 and C# 3.0 (C# in Depth)—with a lot of background
on the hows and whys of LINQ.
Test Yourself
You can test yourself by taking the LINQ Quiz and then reading the 10 LINQ Myths. If you were suprised by any of those myths, do yourself
a favor and follow the three-step LINQ Initiation Process:
- Put aside an afternoon to read the LINQ
Pocket Reference
- Work through the examples in LINQPad
- Take the LINQPad Challenge!