Answer the question
In order to leave comments, you need to log in
How to do OR instead of AND?
I have a request, and in it the
Competenies filter filters people in such a way that ALL competencies are in people, but I need at least one person to have one.
public IEnumerable CompetencyIds => this.CompetencyId.ParseIntArray();
I tried this
qpeople = qpeople.Where(x => x.CompetencyAssignments.Any(ca => ca.CompetencyId == filter.CompetencyIds.SingleOrDefault()));
But this caused an error.
Help a newbie please :)
Answer the question
In order to leave comments, you need to log in
sorry, LINQ is a bit not mine, but logically,
you select a list of people in the loop (from the loop already filtered at the last step) - people with the desired attribute.
essentially cutting off more and more people each time.
but it is necessary once to find people who have at least one sign.
so the correct thing to do was to create a list of all "competencies"
and then check
qpeople = qpeople.Where(x => x.CompetencyAssignments.Any(ca =>filter.CompetencyIds.Contains(ca.CompetencyId));
and without a loop. they just chose people) if it is really necessary that "if at least something from the required list is present)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question