Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

EFCore array intersection

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading