title: Make a DropDownList Distinct
body: <p>Database Table:</p>
  
  <pre><code>|ID|      |Athlete|        |Sport|
   1     Jacoby Ellsbury     Baseball
   2     Dustin Pedroia      Baseball
   3      Kobe Bryant        Basketball
   4      Lebron James       Basketball
   5     Patrick Kane         Hockey
   6     Sidney Crosby        Hockey
  </code></pre>
  
  <p>I want to create a <em>dropdownlist</em> of only the <code>Sport</code> property on my Create action</p>
  
  <p>What I have tried:</p>
  
  <pre><code>ViewBag.Sport = new SelectList(db.AthleteTable.Distinct(), "ID", "Sport");
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>ViewBag.Sport = new SelectList(db.AthleteTable, "ID", "Sport").Distinct();
  </code></pre>
  
  <p>CSHTML:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      @Html.LabelFor(model =&gt; model.Sport, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.DropDownList("Sport", null, "-- Select Sport --", htmlAttributes: new { @class = "form-control" } )
              @Html.ValidationMessageFor(model =&gt; model.Sport, "", new { @class = "text-danger" })
          &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This renders my dropdownlist but the values repeat so:</p>
  
  <pre><code>Baseball
  Baseball
  Basketball
  Basketball
  Hockey
  Hockey
  </code></pre>
  
  <p>What I want:</p>
  
  <pre><code>Baseball
  Basketball
  Hockey
  </code></pre>
  
  <p>Any help is appreciated.</p>
  
  <p>UPDATE:</p>
  
  <p>the reason why my table is like this is because I can create other dropdownlists and separate each Athlete by Sport like so:</p>
  
  <pre><code>List&lt;SelectListItem&gt; lstAthletes = new List&lt;SelectListItem&gt;();
  
          using(var context = new ConnectionString())
          {
              List&lt;AthleteTable&gt; lstAthletes = context.AthleteTable.ToList();
              var groups = lstAthletes.GroupBy(x =&gt; x.Sport);
              foreach(var group in groups)
              {
                  var slg = new SelectListGroup() { Name = group.Key };
  
                  foreach(AthleteTable athlete in group)
                  {
                      SelectListItem item = new SelectListItem() { Text = athlete.Athlete, Value = athlete.ID.ToString(), Group = slg };
                      lstAthletes.Add(item);
                  }
              }
  
          }
  </code></pre>