title: Datetime.UtcNow in Entity Framework query evaluated different than DateTime.UtcNow in C# IL
body: <p>Are DateTime functions in an EF query evaluated by the SQL Server, as where DateTime functions outside of the query expression are evaluated by the machine running the IL?</p>
  
  <p>I have an application that has SalesOrders</p>
  
  <pre><code>public class SalesOrder
  {
     public Int32 OrderID {get;set;}
     public DateTime Expiration {get;set;} 
  }
  </code></pre>
  
  <p>I run an EF query and get different results when I do this:</p>
  
  <pre><code>DateTime utcnow = DateTime.UtcNow;
  
  var open = (from a in context.SalesOrders
              where a.Expiration &gt; utcnow
              select a).ToList();
  </code></pre>
  
  <p>Than when I do this:</p>
  
  <pre><code>var open = (from a in context.SalesOrders
              where a.Expiration &gt; DateTime.UtcNow
              select a).ToList();
  </code></pre>
  
  <p>I think this is because DateTime.UtcNow in an Entity Framework query is evaluated by the SQL Server, vs DateTime.UtcNow outside of the query is evaluated by the machine that's running the IL; <a href="https://stackoverflow.com/a/2585418/439627">I'm basing that off this answer</a>. </p>
  
  <p>I'm in Azure platform as a service, debugging locally with an Azure SQL DB, if that matters. </p>