title: Validate dropdown item does not occur more than once in a list of dropdown fields with the same id
body: <p>I have a form where the user can add as many rows as needed. Each time they are expected to select a different option from the dropdown list provided. At the moment there is no validation to stop them selecting the same value multiple times.</p>
  
  <p><a href="https://i.stack.imgur.com/bfN52.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bfN52.png" alt="enter image description here"></a></p>
  
  <p>Each row is a "ResourceCount".
  The ViewModel has an IList of ResourceCountViewModel, so each row is being added as an item to the list.</p>
  
  <p>The ResourceCount view model consists of an "id" to store the dropdown value selected and a "quantity" for the number field.</p>
  
  <p>I can't think of a way to use the Compare annotation in this scenario.
  How can I implement appropriate validation for this?</p>
  
  <p>EDIT:
  There is lots of good advice in the accepted answer. I went with a simple check in the controller post action:</p>
  
  <pre><code>if (resourceCounts.Count != resourceCounts.Where(d =&gt; d.Id!= 0)
                                            .Select(x =&gt; x.Id)
                                            .Distinct()
                                            .Count())
  {
  
  ModelState.AddModelError(string.Empty, "You can't select the same option more than once");
  //etc.
  
  }
  </code></pre>