A
A
Anton2019-04-04 15:20:05
C++ / C#
Anton, 2019-04-04 15:20:05

How to do OR instead of AND?

I have a request, and in it the
5ca5f539bda6e865867710.png
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

2 answer(s)
D
Denis Gaydak, 2019-04-04
@anton_mra

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)

J
John_Nash, 2019-04-04
@John_Nash

so that ALL competencies are in people, but I need at least one in a person.

qpeople.Where(x => condition1 || condition2)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question