GuyBehindtheGuy (2) [Avatar] Offline
#1
The implementation of
IQueryProvider.CreateQuery(Expression expression)
on page 329 is dangerous and wrong. It constructs and returns an IQueryable<object>, disregarding Expression.Type. It is also in stark contrast to Microsoft's recommended implementation:
http://msdn.microsoft.com/en-us/library/bb546158.aspx

This just cost us several days to track down, because it insidiously causes the IQueryProvider implementation to return different results depending on if the generic vs. non-generic CreateQuery method is called.

While I understand that the full (and correct) implementation of CreateQuery may not have fit the spirit of the example (a simple IQueryProvider implementation), there needs to be a comment next to it akin to:
// Don't do this in production code!
jon.skeet (451) [Avatar] Offline
#2
Re: IQueryProvider implementation
Thanks for that - I'm just starting to work on revising chapter 12. Will fix this as I go.

Also added a note: http://csharpindepth.com/ViewNote.aspx?NoteID=160
GuyBehindtheGuy (2) [Avatar] Offline
#3
Re: IQueryProvider implementation
BTW--the book is great, and I recommend it to everyone who interviews with us!