EF Core with Postgres can't translate Array.Contains() query

Viewed 1418

I have an entity with field defined as array of GUIDs. And I want to know if there some rows in DB which field contains value passed as argument.
According to docs I'm able to make a .Where(x => x.ArrayField.Contains(arg)) or .Where(x => x.ArrayField.Any(f => f == arg)) (also can wrap arg into a single-element array and do .Any(f => array.Contains(f))) call.
But in fact I'm getting this:

System.InvalidOperationException: Error generated for warning 'Microsoft.EntityFrameworkCore.Query.QueryClientEvaluationWarning: The LINQ expression 'where {[x].Ids => Contains(Id_2)}' could not be translated and will be evaluated locally.'. This exception can be suppressed or logged by passing event ID 'RelationalEventId.QueryClientEvaluationWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.

My query looks like this:

var entities = await context.Query<Entity>
    .Where(x => x.Ids.Contains(Id))
    .ToArrayAsync();

Why it is wrong? Or there should be some extra-configuration?
On DB side column defined as uuid[]. I'm not a Postgre pro, but assume it's enough for database.

UPD: the field is defined on C# side as IReadOnlyCollection<Guid>. Can this be a reason for the translator to fail?

UPD2: changing Ids types to Guid[] or IEnumerable<Guid> didn't help. The same error.

0 Answers
Related