title: How to Distinct List<OrderDetails> based on one values from OrderDetails
body: <p>I have order details:</p>
  
  <pre><code>public class OrderDetails
      {
          public int OrderId { get; set; }
         // [DataMember]
          public int ProductId { get; set; }
      }
  </code></pre>
  
  <p>Now if I do a distinct like below , it returns everything:</p>
  
  <pre><code>List&lt;OrderDetails&gt; orderDetails = new List&lt;OrderDetails&gt;();
  ---------------------------------
  return orderDetails.Distinct();
  </code></pre>
  
  <p>But if I do distinct like :</p>
  
  <pre><code>  List&lt;OrderDetails&gt; orderDetails = new List&lt;OrderDetails&gt;();
      ---------------------------------
  return orderDetails.Select(x =&gt; x.OrderId).Distinct();
  </code></pre>
  
  <p>Then I get only Order Ids.</p>
  
  <p>How can I get the Distinct Orderdetails(both OrderID and ProductId)  based on OrderId</p>