title: Entity Framework - DateTime in the where clause
body: <p>I'm trying to convert this code from a stored procedure into a "LINQ to Entities" query:</p>
  
  <pre><code>select * from myTable
  where venue_date + start_time &lt;= @EndDate
  and dateadd(minute, duration * 24 * 60, venue_date + start_time) &gt;= @StartDate
  </code></pre>
  
  <p>As you can see there is some manipulation of dates. This sort of thing won't work because functions such as <code>.AddHours()</code> are not supported:</p>
  
  <pre><code>where b.Venue_Date.Value.AddHours(b.Start_Time.Value.Hour) &lt;= request.EndDate
  </code></pre>
  
  <p>Something like this won't work either. The error says something about not supporting constructors with parameters:</p>
  
  <pre><code>where new DateTime(b.Venue_Date.Value.Year, b.Venue_Date.Value.Month,
    b.Venue_Date.Value.Day, b.Start_Time.Value.Hour, b.Start_Time.Value.Minute,
    b.Start_Time.Value.Second) &lt;= request.EndDate
  </code></pre>
  
  <p>It seems that the Entity Framework is VERY restrictive when dealing with dates. I guess I'll have to use a procedure. The next problem is figuring out how to make a procedure that can populate several related object collections.</p>