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
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:
LINQ to SQL

I am curious if anyone could recommend a hosting company that is running, or has announce when they will be, IIS7 servers now that it is released.
I have looked around MaximumASP‘s site and have yet to find anything regarding a timeframe. Plus I am finding that several smaller shared hosting sites will fill my needs as well as a dedicated or virtual dedicated server does, for a decent amount less.
Preferably, they would not charge a per domain pointer fee.

I finally found time to work on DevExamples.com again and thought I would check on the suggestion that Richard had left on Got my nice Urls working about using incremental LINQ.
Overall I found that I liked the following syntax much better
var cats = this.Categories.Where(c => c.Name == navList.First().Value);
foreach (var item in navList.Skip(1))
{
string name = item.Value;
cats = cats.Where(c => c.Name == name);
}
cat = cats.First();
Unfortunately this only works for the first parent in the hierarchy. After the first parent, it continues to simply work off of the single join. The problem is that instead of generating
it is generating
I think I understand why I am getting this result, though it was not what I was hoping.
In the end I think I will stick with how I implemented it in Got my nice Urls working until I either think of, or run into, a way to do it with lambda expression. Plus I like the Sql generated in the previous post a little better mostly for trace readability.
Technorati Tags:
LINQ to SQL
