title: MVC Get data from multiple tables in database for specific user
body: <p>I'm new to MVC, currently running MVC 2, done a lot av regular ASP.Net in the past.</p>
  
  <p><strong>Background</strong><br>
  Have a database containing all the tables for the .Net Membership provider.<br>
  Created a table called "Lists" containing <code>UserID</code>, <code>ListID</code>, <code>ListName</code> and so on.<br>
  It has a relationship key to the .Net Membership User, UserID column.<br>
  There is also a "List_Items" table that has <code>ListID</code>, <code>ItemID</code>, <code>ItemName</code> and so on.  </p>
  
  <p><strong>What I have done</strong>
  I managed to create a Entity Data Model mapping to the database. It contains both tables.<br>
  In the view I have done this:  </p>
  
  <pre><code>&lt;ul&gt;
   &lt;% foreach (var item in Model) { %&gt;
     &lt;li&gt;&lt;a href="#&lt;%= Html.Encode(item.ListID) %&gt;"&gt;&lt;%= Html.Encode(item.ListName) %&gt;&lt;/a&gt;&lt;/li&gt;
   &lt;% } %&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>In the controller I have done this:  </p>
  
  <pre><code>private ToDoDBEntities _db = new ToDoDBEntities();
  return View(_db.Todo_Lists.ToList());
  </code></pre>
  
  <p>This I got from the asp.net/mvc tutorials. This tells me to things... I get all the Lists for all users. And I don't get the List Items from the other table.</p>
  
  <p><strong>What I want to do</strong>
  I want to be able to pass the Provider Userkey to the database, for the logged on user, so I only get's his/hers lists.<br>
  I also would like to get Lists table and List Items table to the view in the same call so I can build the UL/IL with the List. And build content divs with the List Items.</p>
  
  <p>Happy for any input.</p>
  
  <p>/K</p>