title: Linq to SQL: DISTINCT with Anonymous Types
body: <p>Given this code:</p>
  
  <pre><code>dgIPs.DataSource = 
      from act in Master.dc.Activities
      where act.Session.UID == Master.u.ID
      select new
      {
        Address = act.Session.IP.Address,
        Domain = act.Session.IP.Domain,
        FirstAccess = act.Session.IP.FirstAccess,
        LastAccess = act.Session.IP.LastAccess,
        IsSpider = act.Session.IP.isSpider,
        NumberProblems = act.Session.IP.NumProblems,
        NumberSessions = act.Session.IP.Sessions.Count()
      };
  </code></pre>
  
  <p>How do I pull the Distinct() based on distinct Address only? That is, if I simply add Distinct(), it evaluates the whole row as being distinct and thusly fails to find any duplicates. I want to return exactly one row for each act.Session.IP object.</p>
  
  <p>I've already found <a href="https://stackoverflow.com/questions/543482/linq-select-distinct-with-anonymous-types">this answer</a>, but it seems to be a different situation. Also, Distinct() works fine if I just select act.Session.IP, but it has a column I wish to avoid retrieving and I'd rather not have to do this by manually binding my datagrid columns.</p>