(You are currently looking at the first edition version of this page. This page is also available for the second and third editions.)

Errata for Chapter 11: Query expressions and LINQ to Objects

P282, third paragraph: Nonsense sentence

The sentence in the third paragraph which currently reads:

There's currently has a single customer: Colin.

should read:

The company currently has a single customer: Colin.

P287, figure 11.4: Incorrect line placement

In figure 11.4 at the bottom of page 287, the middle line of the group labeled "Query expression contextual keywords" is meant to point at the word "in". I have prepared a replacement figure to show how it's meant to look.

P292: Missing "AllDefects" twice

On P292, near the top, I claim that:

from defect in SampleData.AllDefects
select defect

is equivalent to

SampleData.Select (defect => defect)

The latter is incorrect - it should actually be:

SampleData.AllDefects.Select (defect => defect)

The sentence following that should read:

There's a big difference between this and the simple expression SampleData.AllDefects, however.

P296, Figure 11.5: Typo in bottom box

The bottom box of figure 11.5 should read:

select new { Name = user.Name, Length = length }

I have prepared a replacement figure to show how it's meant to look.

P300, centre of page: Incorrect signature of "Join" method

The signature of the Join method in the middle of page 300 is incorrect - the innerKeySelector parameter should be of type Func<TInner,TKey>. In addition, it would be clearer to use TOuter instead of T. This affects the previous paragraph as well, giving this as the replacement:

Inner joins are translated by the compiler into calls to the Join method. The signature of the overload used for LINQ to Objects is as follows (when imagining it to be an instance method of IEnumerable<TOuter>):
IEnumerable<TResult> Join<TInner,TKey,TResult> (
   IEnumerable<TInner> inner,
   Func<TOuter,TKey> outerKeySelector,
   Func<TInner,TKey> innerKeySelector,
   Func<TOuter,TInner,TResult> resultSelector
)

This should be corrected for the second edition.

P303 and P306: More signature changes

The signatures of GroupJoin and SelectMany on pages 303 and 306 respectively are currently expressed as if they were methods of IEnumerable<T>. They might be clearer (and match MSDN) if the type parameters were named TOuter and TSource respectively. This would give the following signature on page 303:

IEnumerable<TResult> GroupJoin<TInner,TKey,TResult> (
   IEnumerable<TInner> inner,
   Func<TOuter,TKey> outerKeySelector,
   Func<TInner,TKey> innerKeySelector,
   Func<TOuter,IEnumerable<TInner>,TResult> resultSelector
)

and this signature on page 306, with a change to the last word of the preceding paragraph as well:

IEnumerable<TResult> SelectMany<TCollection,TResult> (
   Func<TSource,IEnumerable<TCollection>> collectionSelector,
   Func<TSource,TCollection,TResult> resultSelector
)

These changes are minor enough not to be worth making for simple reprints, but should be rolled into any more widespread reprints.