Lee Dumond (29) [Avatar] Offline
#1
On page 151, there is a bit of code showing how a query could be formed to show the number of books for each publisher in a separate column:

from book in SampleData.Books
group book by book.Publisher into publisherBooks
select new {
Publisher = publisherBooks.Key.Name,
Books = publisherBooks,
publisherBooks.Count() };

However, this code yields the following error:

Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
fabrice.marguerie (224) [Avatar] Offline
#2
Re: Possible error on page 151?
Lee,

Thank you for pointing this out. I've just added this to the errata.
This code worked with preview releases of LINQ, but with the final version, we have to write the following:

from book in SampleData.Books
group book by book.Publisher into publisherBooks
select new {
Publisher = publisherBooks.Key.Name,
Books = publisherBooks,
Count = publisherBooks.Count() };

Fabrice