title: How to filter data by category in Entity Framework Core?
body: <p>I'm trying to filter the data coming from a query based on the parameters managerId, projectManagerId and resourceId, however, I'm not sure if this is the best way to do this.</p>
  
  <p>I also need these parameters to function as category and the data to be filtered according to the selected item, if selected managerId the result has to be only those projects that are in that managerId, if selectedId manager, and resourceId, returns only those projects that contain those parameters, as if it were a cascaded filter, however, I have no idea how.</p>
  
  <pre><code>public override IEnumerable&lt;Projeto&gt; AllByFilter(int? gestorId, int? projectManagerId, int? recursoId) =&gt;
         _appContext.Projetos
                    .Select(n =&gt; new Projeto
                                 {
                                     Id = n.Id,
                                     ProjectManager = n.ProjectManager,
                                     Gestor = n.Gestor,
                                     ProjetoRecursos = n.ProjetoRecursos
                                                        .Select(q =&gt; new ProjetoRecurso { Recurso = q.Recurso })
                                                        .Where(x =&gt; x.Recurso.Id == recursoId).ToList()
                                 })
                    .Where(x =&gt; x.Gestor.Id == gestorId &amp;&amp; x.ProjectManager.Id == projectManagerId)
                    .ToList();
  }
  </code></pre>