Given a DBSet<Tasks>
with a column tags text[]
. Is there a way in EF Core Npgsql to query for tags in common with a supplied list of tags using the Postgres overlap (&&) operator e.g.
select * from tasks where tag && '{bug, feature}'
I can't find anything related to this, and I'd like to avoid client-side evaluation. I'd like to do something like
var tags = new List<string> { "bug", "feature" };
var foo = _db.Tasks.Where(x => x.Tags && tags); // obviously this doesn't work
I also tried the linq contains method
var foo = _db.Tasks.Where(x => x.Tags.Any(x => tags.Contains(x)));
but received the exception that the linq expression could not be translated.
Support for array overlap (&&) and containment (@>) has been added for version 3.1, which should be released very soon (see https://github.com/npgsql/efcore.pg/issues/1135).
If any other operators are needed and not translated, please open a new issue.