title: Unable to cast object of type 'WhereListIterator`1[Web.Model.Appointment]' to type 'Web.Model.Appointment'
body: <p>This is a code fragment from my controller</p>
  
  <pre><code>[HttpPost]
  public ActionResult Cancel(string id,FormCollection collection)
  {
     //This is how I would like to declare appt but I cannot seem to correctly pass id into this method
     //var appt = Application.Session.GetObjectFromOid&lt;Appointment&gt;(new ObjectId(id));
  
     //I am trying to do it this way instead but I get an error
     var appt = (Appointment)Application.Appointments.Where(a=&gt;a.Id.Equals(collection["Id"]));
     .....
  }
  </code></pre>
  
  <p>This is the error that I get:Unable to cast object of type 'WhereListIterator`1[Web.Model.Appointment]' to type 'Web.Model.Appointment'.</p>
  
  <p>This is my view:</p>
  
  <pre><code>&lt;input type="button" value="Save" onclick="updateCancel(); return false;" /&gt;&lt;button&gt;Save&lt;/button&gt;
  </code></pre>
  
  <p>and this is my function</p>
  
  <pre><code> function updateCancel() {
      $('#cancel').ajaxSubmit({
  
      });
      }
  </code></pre>
  
  <p>So why am I getting this error?
  OR is there a way to pass Model.Data.Id into my function so that I can just use id instead?</p>