title: Passing a WHERE clause for a Linq-to-Sql query as a parameter
body: <p>This is probably pushing the boundaries of Linq-to-Sql a bit but given how versatile it has been so far I thought I'd ask.</p>
  
  <p>I have 3 queries that are selecting identical information and only differ in the <em>where</em> clause, now I know I can pass a delegate in but this only allows me to filter the results already returned, but I want to build up the query via parameter to ensure efficiency.</p>
  
  <p>Here is the query:</p>
  
  <pre><code>from row in DataContext.PublishedEvents
  join link in DataContext.PublishedEvent_EventDateTimes
      on row.guid equals link.container
  join time in DataContext.EventDateTimes on link.item equals time.guid
  where row.ApprovalStatus == "Approved"
      &amp;&amp; row.EventType == "Event"
      &amp;&amp; time.StartDate &lt;= DateTime.Now.Date.AddDays(1)
      &amp;&amp; (!time.EndDate.HasValue || time.EndDate.Value &gt;= DateTime.Now.Date.AddDays(1))
  orderby time.StartDate
  select new EventDetails
  {
      Title = row.EventName,
      Description = TrimDescription(row.Description)
  };
  </code></pre>
  
  <p>The code I want to apply via a parameter would be:</p>
  
  <pre><code>time.StartDate &lt;= DateTime.Now.Date.AddDays(1) &amp;&amp;
  (!time.EndDate.HasValue || time.EndDate.Value &gt;= DateTime.Now.Date.AddDays(1))
  </code></pre>
  
  <p>Is this possible? I don't think it is but thought I'd check out first.</p>
  
  <p>Thanks</p>