Skip to content

Translate Array.Take(n).SequenceEquals(foo) #3633

Description

@InspiringCode

I have a class with an array property:

publicclassPart{publicintId{get;set;}publicint[]TaxonomyPath{get;set;}}

Now I want to query for all Parts where TaxonomyPath starts with [1, 2]:

int[]expected=[1,2];awaitdbContext.Parts.Where(x =>x.TaxonomyPath.Take(2).SequenceEquals(expected)).ToArrayAsync();

I expect this to translate to WHERE "TaxonomyPath"[1:2] = ARRAY[1,2]. Unfortunately this query can't be translated by Npgsql.EntityFrameworkCore.PostgreSQL 9.0.4.

The interesting thing is that Take(2) alone can be translated, and SequenceEquals alone can also be translated.

Is there any way to work around this limitations until this gets fixed (except restored to RawSql)?

I think this is really useful for working with hierarchical tree-like data!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions