这是indexloc提供的服务,不要输入任何密码
Skip to content

Translate Array[][].Contains(x.<array property>) #3634

@InspiringCode

Description

@InspiringCode

I encountered another issue regarding arrays.

I have a class with an array property:

public class Part {
    public int Id { get; set; }
    public int[] TaxonomyPath { get; set; }
}

Now I want to query for all Parts where TaxonomyPath is in [[1, 2], [4,7], [3,9]]:

int[][] expected = [[1, 2], [4,7], [3,9]];
await dbContext.Parts
    .Where(x => expected.Any(e => x.TaxonomyPath.SequenceEqual(e)))
    .ToArrayAsync();

This throws:

Expression 'unnest(@__existing_0) WITH ORDINALITY AS e(value)' in the SQL tree does not have a type mapping assigned.

When I change SequenceEqual to == it throws:

Couldn't find array type mapping when applying item/array mappings

Same when using Where(x => expected.Contains(x.TaxonomyPath).

Also when joining (which is the actual goal):

int[][] expected = [[1, 2], [4,7], [3,9]];
await dbContext.Parts
            .Join(expected,
                x => x.TaxonomyPath,
                x => x,
                (p, _) => p)
    .ToArrayAsync();

It throws:

Expression 'unnest(@__p_0) WITH ORDINALITY AS p(value)' in the SQL tree does not have a type mapping assigned.

I am using Npgsql.EntityFrameworkCore.PostgreSQL 9.0.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions