Skip to content

No translation for dictionary indexer on jsonb columns #1529

@ColonelBundy

Description

@ColonelBundy

Consider the following entity:

public class User
{
      [Key]
      public Guid Id { get; set; }

      [Column(TypeName = "jsonb")]
      public Dictionary<string, object> Properties { get; set; }
}

And then querying:

context.User.Where(x => x.Properties["something"] == "something else").ToList();

Ends up not being able to translate.

Translating the method call of get_Item to something npgsql can understand has proven to be difficult. And one would assume translating it into the proper binding is not possible due to the dynamic nature. I would assume some internal work is needed to properly translate get_Item into sql directly instead.

I looked into perhaps doing a custom Visitor to handle this case but my Expression knowledge lacks in this case and it does not seem possible in the end anyways.
Also to clarify, changing the dictionary to a JsonDocument type is not warranted in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions