Skip to content

Operation translation for List<T> #395

Closed

Description

@roji

We now support mapping CLR List<T> to PostgreSQL arrays (#392). We also have some nice operation translations for regular CLR arrays, but should also translate operations for List<T>, which is supported for mapping PostgreSQL arrays.

Activity

  1. added this to the 2.1.0 milestone on May 13, 2018
  2. austindrenski commented on May 27, 2018

    @austindrenski
    Contributor

    @roji Has anyone started working on this?

    If not, I can start scoping out what we could translate in time for 2.1.

  3. roji commented on May 27, 2018

    @roji
    MemberAuthor

    Feel free to work on this, at least some things should be fairly easy. As a first goal it would be good to achieve party with what is already translated for arrays (length, indexing...)

  4. modified the milestones: 2.1.0, 2.2.0 on May 31, 2018
  5. modified the milestones: 2.2.0, 3.0.0 on Dec 6, 2018
  6. modified the milestones: 3.0.0, 3.1.0 on Sep 24, 2019
  7. modified the milestones: 3.1.0, 5.0.0 on Dec 1, 2019
  8. roji commented on Jan 1, 2020

    @roji
    MemberAuthor

    See some work done based on the old query pipeline in #541

  9. 1 remaining item

  10. added 5 commits that reference this issue on Jan 6, 2020
    954a837
    688adf9
    966929b
    3aa6b64
    6759e00
  11. added a commit that references this issue on Jan 10, 2020
    e013f0e
  12. ryanelian commented on Feb 23, 2020

    @ryanelian

    Excuse me, does this mean that:

                var origins = new List<string> { origin };
    
                var results = DB.Clients
                    .Where(Q => origins.All(item => Q.AllowedCorsOrigins.Contains(item)))
                    .AsNoTracking()
                    .AnyAsync();

    Is now supported?

    (Will it translate to:)

    SELECT * FROM mytable WHERE myarray @> ARRAY['item'];
  13. roji commented on Feb 23, 2020

    @roji
    MemberAuthor

    @ryanelian yes, that should work - it's very similar to this test. Give it a try and please open a new issue if you run into trouble.

  14. JohnC-Ditno commented on Oct 1, 2020

    @JohnC-Ditno

    Could someone confirm whether the following partial matching using Any and Contains is supported?

    var partialOrigin = "http://";
    
    var results = DB.Clients
    .Where(Q => Q.origins.Any(item => item.Contains(partialOrigin)))
    .AsNoTracking()
     .AnyAsync();
    
  15. roji commented on Oct 3, 2020

    @roji
    MemberAuthor

    @JohnDitno take a look at #395 (comment). I'd recommend trying to reference 5.0.0-rc1 and giving it a try to be sure.

  16. SommerEngineering commented on Oct 29, 2020

    @SommerEngineering

    @JohnDitno Unfortunately it does not work, at least in our case:

    The LINQ expression 'DbSet<Entry>()
        .Where(e => e.IsLatestRevision)
        .Where(e => e.EditTime >= __request_ShowSince_0)
        .Where(e => !(e.IsArchived))
        .Where(e => !(e.IsDeleted))
        .OrderBy(e => e.Name)
        .Where(e => e.Competencies
            .Any(i => i.Contains(__searchTerm_1)))' could not be translated.
    

    It does not matter if Entry.Competencies is List<string> or string[]. Both fails with the shown exception.

    I used:

    • .NET 5.0 RC2 and <TargetFramework>net5.0</TargetFramework>
    • <PackageReference Include="Npgsql" Version="5.0.0-preview1" />
    • <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0-rc2" />
    • PostgreSQL 12.2 server

    @ryanelian Should I open a new issue for that?

  17. JohnC-Ditno commented on Oct 29, 2020

    @JohnC-Ditno

    @SommerEngineering thanks for responding to my query.

    That is a shame it doesn't seem to work still, hopefully it can be fixed as we have a similar scenario to your case.

  18. roji commented on Oct 29, 2020

    @roji
    MemberAuthor

    @SommerEngineering your query is very different from a simple Contains in a Where clause - can you please open a new issue?

    If Competencies is a list (or array) of string, are you searching whether one of its strings contains a specific character? Posting a full code sample (including your model) could help clarify what you're trying to do.

  19. SommerEngineering commented on Nov 2, 2020

    @SommerEngineering

    Thanks @roji for your response. I created issue #1554 with a minimal repo to reproduce the case 🙂

    @JohnDitno In my repo for issue #1554 you find different attempts to archive this functionality. No one works, if partial matching is necessary. Searching for exact matches in array columns works, though. This is might a workaround until we get the issue solved.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions