title: How do I use Linq-to-sql to iterate db records?
body: <p>I <a href="https://stackoverflow.com/questions/2595052/what-is-the-preferred-method-of-building-extremely-lightweight-business-object">asked on SO a few days ago</a> what was the simplest quickest way to build a wrapper around a recently completed database.  I took the advice and used sqlmetal to build linq classes around my database design. </p>
  
  <p>Now I am having two problems.   One, I don't know LINQ.  And, two, I have been shocked to realize how hard it is to learn.  I have a book on LINQ (Linq In Action by Manning) and it has helped some but at the end of the day it is going to take me a couple of weeks to get traction and I need to make some progress on my project today.  </p>
  
  <p>So, I am looking for some help getting started.</p>
  
  <p>Click <a href="http://www.spearsofttech.com/wp-content/uploads/2010/04/schema.png" rel="nofollow noreferrer">HERE</a> To see my simple database schema.<br>
  Click <a href="http://www.spearsofttech.com/html/code.html" rel="nofollow noreferrer">HERE</a> to see the vb class that was generated for the schema.  </p>
  
  <p>My needs are simple.  I have a console app. The main table is the SupplyModel table.  Most of the other tables are child tables of the SupplyModel table.  </p>
  
  <p>I want to iterate through each of Supply Model records.   I want to grab the data for a supply model and then <strong>DoStuff</strong> with the data.  And I also need to iterate through the child records, for each supply model, for example the NumberedInventories and <strong>DoStuff</strong> with that as well. </p>
  
  <p>I need help doing this in VB rather than C# if possible.  I am not looking for the whole solution...if you can supply a couple of code-snippets to get me on my way that would be great.</p>
  
  <p>Thanks for your help.  </p>
  
  <p><strong>EDIT</strong><br>
  For the record I have already written the following code...</p>
  
  <pre><code>Dim _dataContext As DataContext = New DataContext(ConnectionStrings("SupplyModelDB").ConnectionString)
  Dim SMs As Table(Of Data.SupplyModels) = _dataContext.GetTable(Of Data.SupplyModels)()
  Dim query = From sm In SMs Where sm.SupplyModelID = 1 Select sm
  </code></pre>
  
  <p>This code is working...I have a query object and I can use ObjectDumper to enumerate and dump the data...but I still can't figure it out...because ObjectDumper uses reflection and other language constructs I don't get.  It DOES enumerate both the parent and child data just like I want (when level=2).  </p>
  
  <p>PLEASE HELP...I'M stuck.  Help!</p>
  
  <p>Seth</p>