title: Distinct on multiple fields
body: <p>I Have a List of some Properties as Model </p>
  
  <pre><code>public class AnswerList {
      public int ID { get; set; }
      public int? Schedule_ID { get; set; }
      public int? SubItemID { get; set; }
      public string SubItemName { get; set; }
      public string ItemName { get; set; }
      public string Answer { get; set; }
      public string Remarks { get; set; }
      public string Remarks_Flag { get; set; }
      public string Lattitude { get; set; }
      public string Longitude { get; set; }
      public DateTime? Load_Date { get; set; }
  }
  </code></pre>
  
  <p>I was getting list of Distinct Sub Items from this List</p>
  
  <pre><code>List&lt;string&gt; sub_item_list = AnswerList.Select(x =&gt; x.SubItemName).Distinct().ToList();
  </code></pre>
  
  <p>Now I want data in different format as per below class</p>
  
  <pre><code>public class SubItemList {
      public string ItemName { get; set; }
      public string SubItemName { get; set; }
  }
  </code></pre>
  
  <p>My requirement is to get distinct sub item with their respective Item Names , Sub Item should be distinct but Item Name can be repeated as one Item can contain multiple Subitem</p>
  
  <p>Distinct Does not work on multiple values so I tried</p>
  
  <pre><code>List&lt;SubItemList&gt; SI_List = 
                   AnswerList.GroupBy(d =&gt; d.SubItemID)
                             .Select(x =&gt; 
                                 new SubItemList 
                           { 
                            ItemName = x.Select(a =&gt; a.ItemName).First(), 
                            SubItemName = x.Select(a =&gt; a.SubItemName).First() 
                           }).Distinct().ToList();
  </code></pre>
  
  <p>This way I am getting what I want but I don't think its a preferable approach ,
  Linq expression inside another Linq expression </p>
  
  <p>How can I get it with a simple Linq expression ?</p>
  
  <p>I am using ASP.Net Core 2.0</p>