I figured out what I was missing

I figured out what I was missing in I think I'm missing something. It was using ".Join" instead of ".Where".

And it turns out that it is a much cleaner implementation then I had done in Got my nice Urls working. So here it is.

var cats = this.Categories.Where(c => c.Name == navList.First().Value);
foreach (var item in navList.Skip(1))
{
    string name = item.Value;
    cats = cats.Join(this.Categories.Where(c => c.Name == name)
        ,c=>c.Key,c=>c.ParentKey.Value,(c,p)=>p);
} 
cat = cats.First();

Which generates the correct Sql bellow

image 

Edit:
Does anyone know if there is a book for LINQ (to SQL in particular) that would be equivilent to Essential Windows Workflow Foundation, that explains how they ended up with the solution they did?

Technorati Tags:

Print | posted on Tuesday, February 05, 2008 11:02 PM

Feedback

# re: I figured out what I was missing

Left by Richard at 2/6/2008 3:40 AM
Gravatar The only item I've see is this from channel9, which comes at it from the opposite direction: why using this structure is so powerful, but only in passing: http://channel9.msdn.com/Showpost.aspx?postid=358968

Your comment:





 
Please add 1 and 3 and type the answer here:

Copyright © Sean Lynch

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski