title: Convert and rearrange List<>
body: <p>I have a list of Training which includes List of Subjects and each subject includes list of Users as follow : </p>
  
  <pre><code>internal class Training
      {
          public string Name { get; set; }
          public List&lt;Subject&gt; Subjects { get; set; }
      }
  
      internal class Subject
      {
          public string Name { get; set; }
          public List&lt;User&gt; Users { get; set; }
      }
  
      internal class User
      {
          public string UserId { get; set; }
          public string FullName { get; set; }
  
      }
  </code></pre>
  
  <p>Now i had to write another class that will return list of Distinct Users and all their training and subjects as follow:</p>
  
  <pre><code>internal class UserData
      {
          public string UserId { get; set; }
          public string FullName { get; set; }
          public List&lt;string&gt; SubjectNames { get; set; }
          public List&lt;string&gt; TrainingNames { get; set; }
      }
  </code></pre>
  
  <p>From the training and subjects i only need their names.</p>
  
  <p>I already wrote the part that reads the database and returns <code>List&lt;Training&gt;</code>  now how can i convert it to <code>List&lt;UserData&gt;</code>?</p>
  
  <p><em>Example</em>:</p>
  
  <p><strong>Input</strong>:</p>
  
  <pre><code>List&lt;Training&gt; trainings;
  </code></pre>
  
  <ul>
  <li>Training ==> .NET</li>
  <li><ul>
  <li>Subject ==> MVC</li>
  </ul></li>
  <li><ul>
  <li><ul>
  <li>User ==> Mike</li>
  </ul></li>
  </ul></li>
  <li><ul>
  <li><ul>
  <li>User ==> John</li>
  </ul></li>
  </ul></li>
  <li><ul>
  <li>Subject ==> ASP.NET</li>
  </ul></li>
  <li><ul>
  <li><ul>
  <li>User ==> Mike</li>
  </ul></li>
  </ul></li>
  <li><ul>
  <li><ul>
  <li>User ==> Kim</li>
  </ul></li>
  </ul></li>
  <li>Training ==> Java</li>
  <li><ul>
  <li>Subject ==> EJB</li>
  </ul></li>
  <li><ul>
  <li><ul>
  <li>User ==> Mike</li>
  </ul></li>
  </ul></li>
  <li><ul>
  <li><ul>
  <li>User ==> Kim</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p><strong>Output</strong> </p>
  
  <pre><code>List&lt;UserData&gt; usersData;
  </code></pre>
  
  <ul>
  <li>UserData==> Mike</li>
  <li><ul>
  <li>Training ==> .NET</li>
  </ul></li>
  <li><ul>
  <li>Training ==> Java</li>
  </ul></li>
  <li><ul>
  <li>Subject ==> MVC</li>
  </ul></li>
  <li><ul>
  <li>Subject ==> ASP.NET</li>
  </ul></li>
  <li><ul>
  <li>Subject ==> EJB</li>
  </ul></li>
  <li>UserData==> John</li>
  <li><ul>
  <li>Training ==> .NET</li>
  </ul></li>
  <li><ul>
  <li>Subject ==> MVC</li>
  </ul></li>
  <li>UserData==> Kim</li>
  <li><ul>
  <li>Training ==> .NET</li>
  </ul></li>
  <li><ul>
  <li>Training ==> Java</li>
  </ul></li>
  <li><ul>
  <li>Subject ==> ASP.NET</li>
  </ul></li>
  <li><ul>
  <li>Subject ==> EJB</li>
  </ul></li>
  </ul>
  
  <p>Hope it's more clear now.</p>