Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lajones opened this issue Oct 12, 2018 · 5 comments · Fixed by #19472
Closed

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

lajones opened this issue Oct 12, 2018 · 5 comments · Fixed by #19472
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 type-enhancement
Milestone

Comments

@lajones
Copy link
Contributor

lajones commented Oct 12, 2018

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).

@lajones lajones self-assigned this Oct 12, 2018
@ajcvickers ajcvickers added this to the 3.0.0 milestone Oct 15, 2018
@ajcvickers ajcvickers modified the milestones: 3.0.0, Backlog Jun 27, 2019
@divega divega changed the title Indexed Properties Feature Indexed properties mapping support Sep 16, 2019
@divega divega changed the title Indexed properties mapping support Indexed properties mapping support (part of property bag entities) Sep 16, 2019
@smitpatel smitpatel assigned smitpatel and unassigned lajones Dec 31, 2019
@smitpatel
Copy link
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?

@AndriySvyryd
Copy link
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

smitpatel added a commit that referenced this issue Jan 1, 2020
smitpatel added a commit that referenced this issue Jan 1, 2020
smitpatel added a commit that referenced this issue Jan 1, 2020
smitpatel added a commit that referenced this issue Jan 1, 2020
smitpatel added a commit that referenced this issue Jan 1, 2020
@smitpatel
Copy link
Contributor

Only fluent API is left now.
I will start with

.IndexedProperty("Id") would be my first suggestion

unless someone brings something better in new year.

smitpatel added a commit that referenced this issue Jan 3, 2020
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jan 3, 2020
@smitpatel smitpatel modified the milestones: Backlog, 5.0.0 Jan 3, 2020
smitpatel added a commit that referenced this issue Jan 4, 2020
smitpatel added a commit that referenced this issue Jan 4, 2020
smitpatel added a commit that referenced this issue Jan 4, 2020
smitpatel added a commit that referenced this issue Jan 4, 2020
smitpatel added a commit that referenced this issue Jan 4, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0, 5.0.0-preview1 Mar 13, 2020
@bigworld12
Copy link

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

@ajcvickers
Copy link
Member

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

@ajcvickers ajcvickers modified the milestones: 5.0.0-preview1, 5.0.0 Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants