title: Entity Framework throws an error when executing a lambda expression
body: <p>I have this piece of code for fetching and filtering results of products from a database:</p>
  
  <pre><code>if (userParams.MinPrice &gt; 0 &amp;&amp; userParams.MaxPrice != 999999999) 
  {
      products = products.Where(p =&gt; (p.Price &gt;= userParams.MinPrice) &amp;&amp; 
                                     (p.Price &lt;= userParams.MaxPrice));
  }
  </code></pre>
  
  <p>This gets executed successfully when only the <code>userParams.MinPrice</code> is provided but fails when <code>userParams.MaxPrice</code> is provided.</p>
  
  <p>The error that I get is this.</p>
  
  <blockquote>
    <p>An unhandled exception has occurred while executing the request.</p>
    
    <p>System.InvalidOperationException: An exception was thrown while attempting to evaluate a LINQ query parameter expression. To show additionalinformation call EnableSensitiveDataLogging() when overriding DbContext.OnConfiguring.</p>
    
    <p>System.NullReferenceException: Object reference not set to an instance
    of an object.    </p>
    
    <p>at lambda_method(Closure )<br>
    at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal.ParameterExtractingExpressionVisitor.Evaluate(Expression expression, String&amp; parameterName).</p>
  </blockquote>
  
  <p>Does anyone know the solution to this? Please help</p>