title: How to Map Lists in c#?
body: <p>Hi I am working in c# and I have two list as below</p>
  <pre><code>public class Table1
  {
      public long Id { get; set; }
      public int mid {get;set;}
      public int ChannelId { get; set; }
      public string Header { get; set; }
      public string FirstData { get; set; }
      public string Type { get; set; }
      public string SubType { get; set; }
      public string Unit { get; set; } 
  }
  </code></pre>
  <pre><code>public class Table2
  {
      public long Id { get; set; }
      public int mid {get;set;}
      public int ChannelId { get; set; }
      public string DateRange { get; set; }
      public string Time { get; set; }
  }
  </code></pre>
  <p>Below is the final List I want</p>
  <pre><code>public class FinalTable
  {
      public long Id { get; set; }
      public int mid {get;set;}
      public int ChannelId { get; set; }
      public string Header { get; set; }
      public string FirstData { get; set; }
      public string Type { get; set; }
      public string SubType { get; set; }
      public string Unit { get; set; } 
      public List&lt;Table2&gt; table2List { get;set;}
  }
  </code></pre>
  <p>So, I have some data in <code>Table1</code> and <code>Table2</code>. I am retrieving these two lists from different sources and finally I have to prepare list in the form of <code>FinalTable</code>.</p>
  <p>In table <code>Table1</code> for each <code>mid</code> and <code>channelid</code> there will be corresponding values in <code>Table2</code> also. This is basically one to many relationship where foreach <code>mid</code> and <code>channelid</code> in table1 there will be multiple entries in <code>Table2</code>.</p>
  <p>So, after mapping finally I would like to show data in the form of <code>FinalTable</code>. FinalTable has property <code>table2List</code> to accomodate table2 data. I can do this by writing multiple or nested foreach loops but what would be the best approach to solve this.</p>