title: Find the last record based on date
body: <p>In my controller, specifically the <em>Create</em> action.. I want one of the textbox's to be auto populated with the value that is in the most recent record based on date.</p>
  
  <p>So for example if on 5/2/2016 the mileage on my car was 26.3.. then when I want to create a record for <code>5/3/2016</code>, the TextBox should be <code>autopopulated</code> with 26.3.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>public ActionResult Create(int? id)
  {
      MaintenanceRecord newMaintenanceRecord = new MaintenanceRecord();
  
      decimal oldMaintenanceRecord = db.MaintenanceRecords.Single(x =&gt; x.AircraftID == id &amp;&amp; x.DateEntered == DateTime.Today.AddDays(-1)).AirFrame;
  
      newMaintenanceRecord.DateEntered = DateTime.Today.Date;
      newMaintenanceRecord.AirFrame = oldMaintenanceRecord;
  
  
      ViewBag.AID = new SelectList(db.AInfoes, "ID", "RegNum");
      return View(newMaintenanceRecord);
  }
  </code></pre>
  
  <p>But when I go to the <em>Create</em> page I receive:</p>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method 'System.DateTime AddDays(Double)' method, and this method cannot be translated into a store expression. </p>
  </blockquote>
  
  <p>So what do I need to modify to retrieve the most recent <code>Airframe</code> in the database based on date?</p>
  
  <p>Any help is appreciated.</p>