0

I use PostgreSQL and have a column codes of type text[], and I have another column filterCodes of type string[]. When I query data from the table, I need to check that codes contains at least one element from filterCodes, I try use Intersection and Any but neither seems to work.

How can I do this without writing custom functions?

patientQuery.Where(p => p.Codes.Intersect(filterCodes).Any());
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Pedro
  • 63
  • 1
  • 7

1 Answers1

1

According to documentation Array Type Mapping (look at translation of array1 && array2)

It should be:

patientQuery = patientQuery
  .Where(p => p.Codes.Any(c => filterCodes.Contains(c)));
Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32