title: Linq to SharePoint with Distinct Results
body: <p>I'm making an alphabetical search filter, and want to get the results from a list and only show the available letter filters based on what results are in the list.  Now the tricky part, the desired column is a people field, and I only want to get the first letter of the person's name.</p>
  
  <p>Right now I can use the following code to query a letter, but who wants to run 26 queries and slow  page loads.  In addition, all the results will show of users that start with the letter a.  So I guess I could do a limit to return only one result, if this was the only option.</p>
  
  <pre><code>SPList UserActivity = web.Lists["User Activity"];
  
  var varUserActivity = (from SPListItem UserActivityItem in UserActivity.Items
                      where UserActivityItem["Username"].ToString().Substring(UserActivityItem["Username"].ToString().IndexOf('#') + 1, (UserActivityItem["Username"].ToString().Length - UserActivityItem["Username"].ToString().IndexOf('#')) - 1).ToLower().Replace("domain\\","").StartsWith("a")
                      select UserActivityItem);
  
  foreach (SPListItem uaitem in varUserActivity)
  {
      this.Controls.Add(new LiteralControl(uaitem["Username"].ToString() + "&lt;br&gt;"));
  }
  </code></pre>
  
  <p>But I prefer to run one query, returning one result for each unique letter.  With this list example data:</p>
  
  <ol>
  <li>DOMAIN\Terra Branford</li>
  <li>DOMAIN\Locke Cole</li>
  <li>DOMAIN\Sabin Figaro</li>
  <li>DOMAIN\Setzer Gabbiani</li>
  <li>DOMAIN\Cyan Garamonde</li>
  <li>DOMAIN\Celes Chere</li>
  <li>DOMAIN\Cid Marquez</li>
  </ol>
  
  <p>...the results expected to return are:</p>
  
  <ol>
  <li>DOMAIN\Terra Branford</li>
  <li>DOMAIN\Locke Cole</li>
  <li>DOMAIN\Sabin Figaro</li>
  <li>DOMAIN\Cyan Garamonde</li>
  </ol>
  
  <p>From here I can build my filter with the letters: C L R S.  So my question is how do I create a distinct Linq query that returns results based on first letter?</p>