title: Searching a DateTime using a search string in Entity Framework code first
body: <p>I have an MVC project which outputs a nullable DateTime (<code>DateTime?</code>) as a string to the user for each model item as shown below (my user interface has paging so I only do this computation for a small number of records - in other words, this part is okay):</p>
  
  <pre><code>foreach (DocumentEvent item in Model.items)
      @(item?.TimeUtc?.ToString() ?? "N/A")
  </code></pre>
  
  <p>I want to add a search functionality. I've tried searching as follows, but this is not performant because <code>AsEnumerable</code> materializes my list and I am now in the C# world, enumerating through each record:</p>
  
  <pre><code>using (var context = new ClientEventsContext())
      var items = context.Events.AsEnumerable().Where(x =&gt; {
          (x?.TimeUtc?.ToString() ?? "N/A").Contains(model.search)
      });
  </code></pre>
  
  <p>Instead I want to take advantage of my SQL Server database. How can I build an SQL Server-friendly query for the above code without <code>AsEnumerable</code> that will produce the same results as my current logic?</p>