title: Populating object properties from DataSet using LINQ
body: <p>Here is my current relationship</p>
  
  <pre><code>DataRelation relation = new DataRelation("EventCategoryRelation", eventsTable.Columns["event_id"], eventCategoriesTable.Columns["event_id"]);
  ds.Tables.Add(eventsTable);
  ds.Tables.Add(eventCategoriesTable);
  ds.Relations.Add(relation);
  </code></pre>
  
  <p>Here is a quick look through the tables</p>
  
  <p><strong>EventsTable</strong></p>
  
  <pre><code>event_id | event_description
  
  1 || "First Event"
  </code></pre>
  
  <p><strong>EventCategoriesTable</strong></p>
  
  <pre><code>event_category_id || event_id || category_id
  
  1 || 1 || 1
  
  2 || 1 || 2
  </code></pre>
  
  <p>Relationship is <strong>many-to-many</strong> (one event is to many categories)</p>
  
  <p>Here is how I populate my DTO's using a foreach loop</p>
  
  <pre><code>foreach (DataRow row in eventsTable.Rows)
  {
      Event events = new Events();
  
      events.Description = row["event_description"].ToString();
  
      DataRow[] aDr = row.GetChildRows("EventCategoryRelation");
      foreach (DataRow dr in aDr)
      {
          Categories category = new Categories();
          category.CategoryID = Int64.Parse(dr["category_id"].ToString());
  
          events.CategoryList.Add(category);
      }
  }
  </code></pre>
  
  <p>I have more fields on my actual code. I want to replace the foreach loop with a LINQ query. Is that possible?</p>