title: Use LINQ to select distinct properties in Lists of Lists
body: <p>I want to use LINQ to select a unique list of strings, stored as a List, inside an object. This object is itself stored in a List inside another object. It's hard to explain, here is an example:</p>
  
  <pre><code>public class Master
  {
     public List&lt;DataCollection&gt; DateCollection { get; set; }
     public Master() { this.DateCollection = new List&lt;DataCollection&gt;(); }
  }
  
  public class DataCollection
  {
     public List&lt;Data&gt; Data { get; set; }
     public DataCollection() { this.Data = new List&lt;Data&gt;(); }
  }
  
  public class Data
  {
     public string Value{ get; set; }
     public Data() {  }
  }
  </code></pre>
  
  <p>Using the Master class, I want to get a list of unique Value strings in the Data class. I have tried the following:</p>
  
  <pre><code>List&lt;string&gt; unique = master.Select(x =&gt; x.DataCollection.Select(y =&gt; y.Value)).Distinct().ToList();
  </code></pre>
  
  <p>Can somebody show me how it's done?</p>