Q:

WPF Treeview using linq to entities multiple relations

I don't know what I'm missing on this:
I have this relationship in my EDM- (can't load a picture yet)
Category_1__many RecipeCategory_many__1_Recipe
Basically every recipe has one or more categories and every category can have 0 or more recipes
Here's my code:
private void LoadData()

    {
        List<Category> Categories = new List<Category>();
        List<Recipe> Recipes = new List<Recipe>();
        var ctx = new MaWEntities();
        var query = from x in ctx.Categories select x;

        Categories = query.ToList<Category>();
        foreach (Category c in Categories)
        {
            TreeViewItem TVP = new TreeViewItem() { Header = c.CategoryName.ToString() };

            var qq = from xx in ctx.RecipeCategories.Where(o => o.CategoryId == c.CategoryId) select xx;
            foreach (var rc in qq)
            {

                TreeViewItem TVC = new TreeViewItem() { Header = rc.Recipe.RecipeName.ToString() };
                TVP.Items.Add(TVC);
                //TVP.IsExpanded = true;
            }
        }

    }

What I am trying to accomplish is a treeview whose parent nodes are the categoryname and child nodes are the recipe name. I know how drill into a relational table from a base table (Recipe to RecipeCategory) using Linq. There MUST also be a way to traverse again to the Category table too.  I should also mention that even if the Category does not have any Recipes I still want to see the Category Name as a parent in the treeview.

A:

I found that my problem in this scenario was not that my code wasn't working; rather that I neglected to ever add the treeview items to my treeview. Also, this addition needs to be done after the foreach loop.             List Categories = new List();
            List Recipes = new List();
            var ctx = new MaWEntities();
            var query = from x in ctx.Categories select x;
        Categories = query.ToList<Category>();
        foreach (Category c in Categories)
        {
            TreeViewItem TVP = new TreeViewItem() { Header = c.CategoryName.ToString() };

            var query2 = from xx in ctx.RecipeCategories.Where(o => o.CategoryId == c.CategoryId) select xx;
            foreach (var rc in query2)
            {

                TreeViewItem TVC = new TreeViewItem() { Header = rc.Recipe.RecipeName.ToString() };
                TVP.Items.Add(TVC);

            }
            tvwRecipe.Items.Add(TVP);
        }

