title: Handling 'Sequence has no elements' Exception
body: <p>I am updating a quantity in my cart, but it is throwing a Sequence has no elements' exception.</p>
  
  <p>And I don't know what that even means. At first I thought that maybe there was a null value being passed somewhere, but that isn't the case, as I've checked that:</p>
  
  <blockquote>
    <p>Sequence contains no elements    Description: An unhandled exception
    occurred during the execution of the current web request. Please
    review the stack trace for more information about the error and where
    it originated in the code. </p>
    
    <p>Exception Details: System.InvalidOperationException: Sequence
    contains no elements</p>
    
    <p>Source Error: </p>
    
    <p>Line 35:                 var uid = WebSecurity.CurrentUserId; Line 36:
    var newqty = Request.Form["Quantity"]; Line 37:<br>
    OModel.Cart c = (from item in database.Carts Line 38:<br>
    where item.UserId == uid &amp;&amp; item.PartNumber == pnumber &amp;&amp; item.OrderId
    == oid Line 39:                                    select item).First();</p>
  </blockquote>
  
  <p>Any ideas what could be causing this?</p>