title: Linq where condition on datetime.ToString()
body: <p>I have following Linq code</p>
  
  <pre><code>// query = IQueryable&lt;DataClass&gt;
  query = query.Where(m =&gt; m.Column1.Contains(model.search.value)
          || m.DateTimeColumn2.ToString("dd.MM.yyyy").StartsWith(model.search.value));
  
  return query.ToList() // here the error is thrown
  </code></pre>
  
  <p>I get <strong>NullReferenceException</strong> error</p>
  
  <blockquote>
    <p>Exception has occurred: CLR/System.NullReferenceException An exception
    of type 'System.NullReferenceException' occurred in
    Microsoft.EntityFrameworkCore.dll but was not handled in user code:
    'Object reference not set to an instance of an object.'    at
    System.Linq.Enumerable.WhereSelectEnumerableIterator<code>2.MoveNext()<br>
    at
    Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor</code>1.EnumeratorExceptionInterceptor.MoveNext()</p>
  </blockquote>
  
  <p>if i commented out the line for 2nd column it works</p>
  
  <pre><code>//|| m.DateTimeColumn2.ToString("dd.MM.yyyy").StartsWith(model.search.value)
  </code></pre>
  
  <p><code>model.search.value</code> is string value I am trying to filter all columns. The DateTimeColumn2 is in DateTime datatype in the database, but user input string, therefore Iam converting DateTimeColumn2 to string and try to filter to users value. Any idea, what I am doing wrong ?</p>