Skip to content

Indexed properties mapping support (part of property bag entities) #13610

Description

@lajones

From discussion with @divega and @ajcvickers. We would like to support Entity classes with indexers:

    public class SomeEntity
    {
        public object this[string propertyName]
        {
            get
            {
                // get value of property named propertyName
            }

            set
            {
                // set value of property named propertyName
            }
        }
    }

You can then declare an indexed property in OnModelCreating() and have EF use the indexer to access that property, instead of expecting a member. (Note: this addresses parts of issues #2968 and #9914).

Activity

  1. self-assigned this
    on Oct 12, 2018
  2. added this to the 3.0.0 milestone on Oct 15, 2018
  3. modified the milestones: 3.0.0, Backlog on Jun 27, 2019
  4. changed the title [-]Indexed Properties Feature[/-] [+]Indexed properties mapping support[/+] on Sep 16, 2019
  5. changed the title [-]Indexed properties mapping support[/-] [+]Indexed properties mapping support (part of property bag entities)[/+] on Sep 16, 2019
  6. smitpatel commented on Dec 31, 2019

    @smitpatel
    Contributor

    Few questions:
    @AndriySvyryd or @ajcvickers if there are already answers or we can discuss in design meeting to decide.

    • Should there be AddIndexedProperty method on IMutableEntityType? Specifying memberInfo is bit cumbersome and if we know we are adding indexed property then we can fetch it from entityType.ClrType directly.
    • Fluent API? or to be discussed later?
    • Fields
      • Can indexer be field in C# (I really don't know)?
      • Current design assumes it to be always a propertyInfo.
      • Indexer properties can be configured to use backing field just like any other property.
      • Is there a need or should we support mapping indexer to a backing field dictionary which would be accessed directly?
  7. AndriySvyryd commented on Dec 31, 2019

    @AndriySvyryd
    Member
    • You can add AddIndexedProperty extension method or default interface implementation as sugar if it's useful.
    • .IndexedProperty<int>("Id") would be my first suggestion
    • Indexers cannot be fields and can't have a backing field
    • We don't need to support Dictionary properties at this point
  8. 19 remaining items

  9. added a commit that references this issue on Jan 4, 2020
    6594428
  10. modified the milestones: 5.0.0, on Mar 13, 2020
  11. bigworld12 commented on Apr 13, 2020

    @bigworld12

    will this issue be related to fixing #13084 and #2968

  12. ajcvickers commented on Apr 13, 2020

    @ajcvickers
    Contributor

    @bigworld12 This issue is unrelated to the two that you mention.

  13. modified the milestones: , 5.0.0 on Nov 7, 2020
  14. added theissue type on Jun 15, 2025
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

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions