title: How to iterate over results of a linq-to-sql query result and append the results?
body: <p>I'm new to C# and Linq-to-Sql.</p>
  
  <p>I've a table 'InstrumentTypes' of this form:</p>
  
  <pre><code>typeId(int)  | type(varchar)  |  subttype(varchar)
  
  101               Keys           keyboard
  102               Keys           accessories
  103               Guitar         acoustic
  104               Guitar         electric
  </code></pre>
  
  <p>I need to fetch all 'typeId's from the table based on a search by 'type' as input, and all the typeId's needed to be bound to a ASP Repeater.</p>
  
  <p>So far I've written the following code:</p>
  
  <pre><code>// requestType contains the type from the search
  var type = (from m in database.InstrumentTypes
              where m.type == requestType
              select m);
  foreach(var typeId in type)
  {
      //code
  }
  </code></pre>
  
  <p>I'm unable to figure out how to iterate over the results from the query, store them in a datastructure and bind them to a Repeater.</p>
  
  <p>The following code binds it to the Repeater:</p>
  
  <pre><code>Repeater1.DataSource= //name of data structure used to store the types goes here
  Repeater1.DataBind();
  </code></pre>
  
  <p>Could anyone please help me out?</p>
  
  <p>EDIT:
  For each typeID obtained, I want to access another table 'Instruments' and retrieve all Instruments belonging to that typeId.
  The table 'Instruments' is like this:</p>
  
  <pre><code>instrumentId     typeID    name     description
  1000             101       yamaha   xyz
  </code></pre>
  
  <p>Based on Arialdo's answer, I'm doing this:</p>
  
  <pre><code>var type = (from m in database.InstrumentTypes
                            where m.type == requestType
                            select m);
              var instruments = new List&lt;Instrument&gt;();
              foreach (var i in type)
              {
                  instruments.Add(from x in database.Instruments
                                  where x.typeId == i.typeId
                                  select x);
              }
              Repeater1.DataSource = instruments;
              Repeater1.DataBind();
  </code></pre>
  
  <p>But I get a compilation error saying 'The best overloaded method match for the List has some invalid arguments'. Where am I going wrong?</p>