EFCore array intersection

Advertisements

I use postgre and have filed int table with type text[] and name codes, and have filterCodes type of string[]. When I query data from table I need to check that codes contains at least one element from filterCodes, I try use Intersection and Any but it don’t works. How I can do tit without writing custom functions.

patientQuery.Where(p => p.Codes.Intersect(filterCodes).Any());

>Solution :

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)));

Leave a Reply Cancel reply