title: LINQ GroupBy and Distinct
body: <p>I am trying to get a set of records that match certain criteria.
  Imagine I have a list of orders, each with a nested account, a bit like this:</p>
  
  <pre><code>var orders = [{
      account: {
          id: 1
      }
  }, {
      account: {
          id: 1
      }
  }, {
      account: {
          id: 2
      }
  }, {
      account: {
          id: 2
      }
  }, {
      account: {
          id: 1
      }
  }, {
      account: {
          id: 4
      }
  }, {
      account: {
          id: 3
      }
  }];
  </code></pre>
  
  <p>I would like to use LINQ to get all the distinct accounts based on the account id.
  I thought I might be able to do something like:</p>
  
  <pre><code>var accounts = results.Select(m =&gt; m.Account).GroupBy(m =&gt; m.AccountNumber).Distinct();
  </code></pre>
  
  <p>but that doesn't appear to work.
  Can someone help me out?</p>