How to add where clause to ThenInclude : <p>I have 3 entities:</p>

<p><code>Questionnaire.cs</code>:</p>

<pre><code>public class Questionnaire
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection&lt;Question&gt; Questions { get; set; }
}
</code></pre>

<p><code>Question.cs</code>:</p>

<pre><code>public class Question
{
    public int Id { get; set; }
    public string Text { get; set; }
    public ICollection&lt;Answer&gt; Answers { get; set; }
}
</code></pre>

<p>and <code>Answer.cs</code>: </p>

<pre><code>public class Answer
{
    public int Id { get; set; }
    public string UserId { get; set; }
    public string TextAnswer { get; set; }
}
</code></pre>

<p>So I saved the questionnaire with answers but now i want to retrieve filtered questionnaire with questions and its answers. So i wrote linq for that, but it throws me an error, is there anything i do wrong? here is the example:</p>

<pre><code>questionnaire = _context.Questionnaires.Include(qn =&gt; qn.Questions)
.ThenInclude(question =&gt; question.Answers.Where(a =&gt; a.UserId == userId))
.FirstOrDefault(qn =&gt; qn.Id == questionnaireId);
</code></pre>

<p>And i am getting </p>

<blockquote>
  <p>Message = "The property expression 'q => {from Answer a in q.Answers
  where Equals([a].UserId, __userId_0) select [a]}' is not valid. The
  expression should represent a property access: 't => t.MyProperty'.</p>
</blockquote>

<p>Any ideas how to solve this problem? </p>
