title: Linq .net core 3.1 When called from 'VisitLambda', rewriting a node of type 'System.Linq.Expressions.ParameterExpression' must return
body: <p>I have a problem with below exception:</p>
  <blockquote>
  <p>When called from 'VisitLambda', rewriting a node of type
  'System.Linq.Expressions.ParameterExpression' must return a non-null
  value of the same type. Alternatively, override 'VisitLambda' and
  change it to not visit children of this type.</p>
  </blockquote>
  <p>it is related to this part of the code:</p>
  <pre class="lang-cs prettyprint-override"><code>var teamEntries = _dataContext.TeamEntriesEntries
      .Where(c =&gt; TeamEntryIds.Contains(c.Id))
      .Include(c =&gt; c.TeamType);
      .Select(c =&gt; new
      {
          UserId = filteredCachedEntries.Any() ? filteredCachedEntries.Where (f =&gt; f.CurrentCalendarEntry != null &amp;&amp; f.CurrentCalendarEntry.Id == c.Id).FirstOrDefault().UserId : 0,
          c.TeamType,
          Status = c.Progress != null ? c.Progress.Status : null,
      })
      .ToList();
  </code></pre>
  <p>Below line cause error (Where):</p>
  <pre class="lang-cs prettyprint-override"><code>UserId = filteredCachedEntries.Any() ? filteredCachedEntries.Where (f =&gt; f.CurrentCalendarEntry != null &amp;&amp; f.CurrentCalendarEntry.Id == c.Id).FirstOrDefault().UserId : 0
  </code></pre>
  <p>in .net core 2.2 everything was ok but right now it doesn't work and show me exceptaion.</p>